12-26-2024 07:18 AM - edited 12-26-2024 07:30 AM
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).
Solved! Go to Solution.
12-26-2024 08:15 AM
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
12-26-2024 04:45 PM
It's an excel file with a csv extension.
12-26-2024 09:13 PM
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:
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
12-27-2024 01:04 AM
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.
12-27-2024 03:03 AM
Do what Bob said and just use write to delimited file.vi to write your data to the file.
12-27-2024 03:23 AM
Ok, thanks for ur help.
12-27-2024 05:42 AM
I did it. I let it here for the other people
12-27-2024 07:51 AM
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