09-13-2021 02:54 AM
Hello,
I try to read a csv file with LabVIEW.
This is my VI for reading the csv file:
This is the ";" delimited csv-file, which I want to read:
This is what I get:
As you can see, there is a "0" in the first column and first row.
Does anybody know what causes this behaviour?
Thank you very much in advance.
Best regards,
Michael
Solved! Go to Solution.
09-13-2021 03:09 AM
Hello Michael,
I assume there is an (or several) additional character(s) at the start of your file.
For further analysis either upload the file or look at it in binary form.
Regards, Jens
09-13-2021 03:23 AM
Hello Jens,
thank you very much for your quick reply.
I attached the the file to this reply.
Best regards,
Michael
09-13-2021 04:25 AM - edited 09-13-2021 04:26 AM
Hi Michael,
as Jens told you: there are some additional bytes at the beginning of your file!
You probably edited that file using a text editor (like Notepad) instead of creating it directly from Excel…
See this view of your textfile using a hex viewer:
The first 3 bytes are used to determine the UTF status of that text file. LabVIEW doesn't handle those bytes explicitely and when reading a delimited text file it tries to convert that file content like any other file content…
09-13-2021 04:38 AM
Your file contains a three-byte Byte Order Mark (BOM) declaring that the file is encoded in UTF-8. In this case, it's a useless information since all characters are ASCII. LabVIEW does not support BOMs anyway.
You may set your editor options to avoid writing the BOM. As an alternative, open your file with Notepad, then choose Save As... setting ASCII as encoding options. See below (doing a little translation to your language):
09-13-2021 06:04 AM
@pincpanter ha scritto:
As an alternative, open your file with Notepad, then choose Save As... setting ASCII as encoding options.
I meant ANSI, not ASCII...
09-13-2021 08:24 AM
I think Notepad will make some guesses according to your localization. I think that it will add BOM if you have non-English localization? Something along those lines?
09-13-2021 09:01 AM
@billko ha scritto:
I think Notepad will make some guesses according to your localization. I think that it will add BOM if you have non-English localization? Something along those lines?
Not always. If I create form scratch a file with non-ASCII-standard characters, Notepad generates a UTF-8 file (i mean with multi-bytes characters), but does not prepend a BOM.
Honestly, all this character representation stuff is often a mess to me.
09-13-2021 11:45 AM
@pincpanter wrote:
@billko ha scritto:
I think Notepad will make some guesses according to your localization. I think that it will add BOM if you have non-English localization? Something along those lines?
Not always. If I create form scratch a file with non-ASCII-standard characters, Notepad generates a UTF-8 file (i mean with multi-bytes characters), but does not prepend a BOM.
Honestly, all this character representation stuff is often a mess to me.
Yes, I'm not sure exactly how it works, either, which is why I avoid working with Notepad.exe if at all possible.
09-14-2021 01:12 AM
Hello GerdW,
you were right. Thank you very much for your reply.
Best regards,
Michael