LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can't read .csv file values with Read Delimited Spreadsheet VI

Solved!
Go to solution

Hi everyone,

 

Im trying to read some values from a .csv file (attached) to plot them later, but all i read are zeros. Idk whats happenning, maybe its something dumb i cant see but i dont find the error.

 

Thank u all in advantage.

 

EDIT: im trying with "," as delimiter an the rows i want to read are 2º (index col: 1) and 4º (index col: 3). 

0 Kudos
Message 1 of 9
(203 Views)

Your .csv file is corrupted.  You should be able to open it with Notepad (or any other text editor), but it won't open properly.  Examining it with something like Notepad++ or similar program that can read (and should show, as largely "readable text", a Comma-separated-variable file, shows a lot of blank or barely-readable sections, with some "text" sections mixed in.

 

Try posting the code you used to generate the .csv file.  You should have used "Write Delimited Spreadsheet.vi", and only that, to write the file.  Note that you don't need to (and shouldn't) open or close the file -- the function takes care of doing that for you, automatically positioning the "write position" at the end of the current file, doing the write, and then closing the file.  While this takes a little extra time to do the write, it means that the file is closed (and "safe") except when you update it.

 

If you post your "writing" code, we'll probably be able to help you find and fix this "reading" problem.

 

Bob Schor

Message 2 of 9
(180 Views)

It's an excel file with a csv extension.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 3 of 9
(152 Views)

Good call, Bill -- I missed that the .csv was not a "Comma-separated-variable" file, but an Excel file with the "wrong" (i.e. misleading) extension.

 

So I double-clicked the attached .csv file,  It declared it was a mal-formed Excel file, but I told it to open it anyway, and found the following:

CSV file opened in Excel.png

 

If you want to write (or read) .csv files, you need to use "Write Delimited Spreadsheet" or "Read Delimited Spreadsheet", found on the File Palette.  If you can't figure it out from the LabVIEW Help (or from your instructor), examine the Example VI mentioned in the Help message.

 

Bob Schor

Message 4 of 9
(140 Views)

Ok, i understand now. Thank both.

 

Yes, it is an excel file with a csv extension because i create the file from a "template" that i create before in excel.

 

Is there anyway to do this from a template?

 

I share u screenshots of th VIs i use to create and write into the file because i can't share the code.

 

0 Kudos
Message 5 of 9
(121 Views)

Do what Bob said and just use write to delimited file.vi to write your data to the file.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 6 of 9
(100 Views)

Ok, thanks for ur help.

0 Kudos
Message 7 of 9
(96 Views)
Solution
Accepted by xespizua

Captura de pantalla 2024-12-27 124230.png

I did it. I let it here for the other people

0 Kudos
Message 8 of 9
(82 Views)

The "solution" to your Message is really my response explaining the difference between an Excel file with the extension ".csv" and a true Comma-separated-variable file, a pure text file (no Excel binary components) created by a LabVIEW File function, "Write Delimited Spreadsheet".

 

If you search this Forum for the phrase "Revised Generate Excel Report Example", you will find a post of mine from 10 years ago that shows how to use the Report Generation Toolkit to build a Report in Excel that has "named cells" (like "Date" and "Operator") that get filled in, a table for multiple channels of data, and even a Graph plotted from these data.  This particular example does not use a Template, but generates what is essentially the entries for the Template at run time.  It would be an easy exercise to create a Template by studying Steps 7 through 11 (and leaving out the parts generating and writing the data), and giving the output file a name like "BS Template.xlsx".  

 

Note that in 2014, the function to create a new report was called "New Report" -- it is now called "Create Report".

 

Bob Schor

0 Kudos
Message 9 of 9
(57 Views)