How can we import text files with space as field separator.
I think, the only possibility is to set the Start/End Fielddelimiter to e.g. <"> and set the field seperator to .
Michael is half correct I think. I tried exporting with the Start/End Delimiter set to <"> and the separator set to , and the file was lined up as such: "Field1""Field2"“Field3” This tells me that a space between the fields for an import file will require the Field Separator property set to " " without the quotes. But Navision will not recognize this as a valid data in the property, and defaults back to the <,> setting. I tried < > as a setting, but the output file ends up being: “Field1”< >“Field2”< >“Field3” So, for your purposes, you absolutely cannot use a space as a field separator. Try another type of seperator (like Tildy ~ or Pipe |). I recommend no Start/End field delimiters at all (not really required, especially with ~ or |). If all you can get is spaces in the file from your source, then use a field delimiter as well, and use Excel to clean up the data. Of course, this is on the basis that you do not have the field delimiter character within the data. Regards! Kristopher Webb Kelar Corporation, Canada
If (repeat: if) the fields are separated by a space (highly uncommon, so please do check again if there’s really no other character - check with an editor capable of displaying hex values), then you can read in the whole line at once and do the split yourself, for example as follows: [code] message(‘As read from file: %1’,WholeLine); SpacePosStart := strpos(Wholeline,’ ‘); SpacePosEnd := 0; //First field is from start till first space import1 := copystr(WholeLine,1,SpacePosStart-1); //Second field starts after first space //First copy full remainder of string import2 := copystr(WholeLine,SpacePosStart+1); //Field 2 ends at next space SpacePosEnd := strpos(import2,’ '); //Cut off after space import2 := copystr(import2,1,SpacePosEnd-1); //Third (last) field starts after last space SpacePostStart := SpacePosStart + SpacePosEnd; import3 := copystr(WholeLine,SpacePosStart+1); message(‘After split: %1%2%3’,import1,import2,import3); [\code] To test this example, I created a text file with 3 words(Test ABC DEF), and a dataport with the Integer table as DataItem (AutoSave, AutoUpdate, AutoReplace all to No), FieldStartDelimiter = , FieldEndDelimiter = , “WholeLine” as SourceExpression for the dataport fields. The code above was placed in the OnAfterImportRecord trigger. Limitation: The WholeLine can be 250 charcters at the most for up to version 2.6x, but with Attain you can go up to 1024 characters. Furthermore, is it a one time job, or a regular repeating import? If a one-time job, use Excel to read the file and save it as CSV. John
Kristopher, your export is o.k… When you create a new table and import this file, you will see,that there will not be an error message. You just have to write None between the brackets= as the field-seperator.