I am creating a dataport that will be used as part of a monthly interface importing invoices into Navision. The import file is comma delimited with text fields enclosed in quotes. If a quote actually exists in a field then the quote is escaped by doubling the quote (e.g. "This is an example of ""escaping"" quotes inside a field").
The Navision dataport handles the comma delimiter, using the FieldSeparator property; and the enclosing quotes using the FieldStartDelimiter and FieldEndDelimiter properties. However, the dataport is not handling the escaped quotes inside fields. When it hits an escaped quote in a field it is treating it as the end of the field, and then the next quote as the start of the next field. The data port then errors with a datatype violation on a field further in the record because the fields are now being read out of place.
I have no control over the format of the import file, as it is created by an outside party. Any suggestions, please, on how to get the dataport to correctly handle the escaped quotes?
0
Answers
You mention IF so are you saying sometimes it could be Double-Double Quotes and Sometimes Not?
Or is it set in stone that it's always Double-Double?
If so just change
FieldStartDelimiter ""
FieldEndDelimiter ""
http://www.BiloBeauty.com
http://www.autismspeaks.org
Thanks for the response. I think I wasn't clear about my description before. The text fields are always enclosed in one set of quotes. However, sometimes a text field, which is enclosed in quotes, actually contains a legitimate quote inside field. In this case the quote in the field is escaped by having two sets of quotes, i.e. "". Here's a sample record in the import file:
01,"55 Audubon Ave ""Grace Salon""","NEW YORK","NY",10032,
The second field in this record is enclosed in quotes but also has legitmate quotes in the filed "Grace Salon" these quotes are escaped by using two sets of quotes ""Grace Salon"".
So I need to keep the FieldStartDelimiter and FieldEndDelimiter = " to account for the enclosing quotes; but I need a way of handling legitimate quotes inside the field. I need the second field in the record above to be inserted into the street address field in the target table as:
55 Audubon Ave "Grace Salon"
I hope this makes sense.
RIS Plus, LLC
Just simple string manipulation.
Or in excel save it as Tab deleminator.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Unless someone can still come up with a better solution in Navision; I think I will have to go with a solution like DenSter proposed, writing a macro in excel to alter the field delimiters from commas to tabs, or something of the like. This will just make fully automating the interface a little more difficult.
Thanks again for the suggestions.
~ is so rarely used anywhere that it's a perfect separator.
Maybe you can ask them to use something other than a comma [-o<
ie..
"Order"~"CS46685"~"Item"~"10000"~"99999"~"1"~"1.50"
"Order"~"CS46685"~"Item"~"20000"~"41132"~"1"~"67.99"
"Order"~"CS46685"~"Item"~"30000"~"41131"~"1"~"67.99"
http://www.BiloBeauty.com
http://www.autismspeaks.org
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Data->Import External Data->Import Data->"The File"
If you pick "other" during the import wizard you can select ~ as your separator too.
----
Anyway if someone is going thru the trouble to create a file for you I find it had to believe that with today's software that they can't help you out. I'd ask O:)
http://www.BiloBeauty.com
http://www.autismspeaks.org
<">
which is the default, and the FieldEndDelimeter to
",
the dataport imports all data without error, because it only considers a quote as terminating a field if the quote was followed by a comma. This method doesn't actually escape the quotes; it imports both the legitimate quotes inside a field and the escaping quotes. So using my previous example, the field from the file
...,"55 Audubon Ave ""Grace Salon""",...
was imported into the target table as
55 Audubon Ave ""Grace Salon""
However, the extra set of quotes can now be eliminated using string manipulation functions.
Thanks again for everyone's suggestions. Hopefully this can help someone in the future also.
And if there is a ',' in the text to be imported? :whistle:
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
True, if there was a legitimate ", inside of the text field then the import would error. This would be extremely rare, if it ever occurs, with the type of data I am importing. If it does happen then we'll have to manually modify the import file - removing the quotes, replacing them with single quotes, etc. - and run the dataport. However; by and large, this solves the problem of being able to automate the interface without paying the vendor to modify their extract file. Thanks for the heads up.
I found this worked for me. However now any data that contains a , will be surrounded by " ". I don't understand why this is happening. Have I missed something?
Dneal
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
FieldStartDelimiter=<NONE>
FieldENDDelimiter=<NONE>
FieldSeparator=<TAB>
Dneal
going back to the original question - have you tried leaving the start & end blank and just using the comma as the field seperator?
The FieldStartDelimeter and the FieldEndDelimiter properties are used to "Quote" the field contents in situations where the data of a field contains the character that is defined as a separator (FieldSeparator, RecordSeparator or DataitemSeparator).
These delimeters are not obigatory. This means that if only one field of a record needs to be quoted, only this field has to be enclosed by the FieldStartDelimeter and the FieldEndDelimiter characters. The other fields can have the delimeters optionally; it will make no difference during importing.
http://www.BiloBeauty.com
http://www.autismspeaks.org