Community of VE/MapPoint Users and Developers
This is a discussion on using ImportData with VBScript within the Development forums, part of the MapPoint 2006/2009 Discussion category; Unfortunately it is not working with the above code. Only if i start the import without this array and a ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Re: using ImportData with VBScript
Unfortunately it is not working with the above code. Only if i start the import without this array and a header line in the file, i can do the import silently - but i have to choose a special header line for the import file to make MapPoint recognizing the content of the columns automatically. Pit |
| |||
| Re: using ImportData with VBScript
Hi, I did a quick test writing to a file and import it using code below. It works very good. Eventually you try it and check for differences. Code: double lat;
double lon;
string fileName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName) + "\\temp.csv";
TextWriter writer = new StreamWriter(fileName, false);
try {
writer.WriteLine("Lat;Lon");
lat = 51;
lon = 4;
for (int k = 0; k < 3000; k++) {
writer.WriteLine(lat.ToString() + ";" + lon.ToString());
lon += .0003;
}
} finally {
writer.Close();
}
MapPoint.DataSet dataSet;
// Define field specification
object[,] fieldSpecifications = null;
fieldSpecifications = new object[2, 2];
// Specify what fields are geographic and what fields are not
fieldSpecifications[0, 0] = "Lat";
fieldSpecifications[0, 1] = MapPoint.GeoFieldType.geoFieldLatitude;
fieldSpecifications[1, 0] = "Lon";
fieldSpecifications[1, 1] = MapPoint.GeoFieldType.geoFieldLongitude;
dataSet = MP.ActiveMap.DataSets.ImportData(fileName,
fieldSpecifications,
MapPoint.GeoCountry.geoCountryDefault,
MapPoint.GeoDelimiter.geoDelimiterSemicolon, 0);
dataSet.Symbol = 37;
dataSet.ZoomTo();
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| Re: using ImportData with VBScript
Thank you for your answer! This code doesn't seem to be VbScript? What Language ist it? C#? writer.WriteLine("Lat;Lon"); means, that you add a header line to that file. In my example I do not add a header line and I use TAB as delimiter, because ; may exist as field content. Pit |
| |||
| Re: using ImportData with VBScript
Hi, Yes example is in C#. Yes I use always a header, maybe that's the reason. But now you can easy compare. I "think" if the delimiting character is in a string and you put the string into quotes "" then you can have it in there. Not sure but easy found with a little experiment.
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
![]() |
| Tags |
| importdata, vbscript |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ImportData | lacja | MapPoint 2006/2009 Discussion | 6 | 11-19-2006 10:57 AM |
| MapPoint 2002 with ASP (vbscript) | eatech | MapPoint 2006/2009 Discussion | 6 | 05-05-2005 05:12 AM |
| ImportData | Anonymous | MapPoint 2006/2009 Discussion | 0 | 11-04-2004 04:05 AM |
| Will Pay $$$ for Assistance - ASP / VBSCRIPT | webdbx | MapPoint 2006/2009 Discussion | 1 | 07-09-2004 09:31 PM |
| Clientside VBScript and MapPoint? | Anonymous | MapPoint 2006/2009 Discussion | 4 | 03-14-2004 06:34 PM |