LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CSV read write to a specific cell

I'm trying to use the following to read and write to a specific cell. (In this case write)

 

LED47_0-1723650934098.png

my question is there a way to send to a specific cell?

 

 

0 Kudos
Message 1 of 6
(307 Views)

A CSV file is basically just a very long string with columns delimited by commas and line by linefeeds. In order to replace the values in a specific cell, you need to read the entire file as 2D array, replace the value, then write everything back.

 

(Only if you can guarantee that each value occupies exactly the same number of bytes, you could calculate an offset into the file and overwrite that location using low-level file IO, but that is fragile.)

0 Kudos
Message 2 of 6
(297 Views)

I think your first suggestion seems doable, give that a try... Thank you

0 Kudos
Message 3 of 6
(281 Views)

Are you sure this is a csv file and not an excel file with a csv extension?  The name of the file sure looks like the default name for an excel spreadsheet.

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.
0 Kudos
Message 4 of 6
(253 Views)

Well I have to admit I'm not that proficient in understanding the Excel-.CSV relationship.

Yes I started out with an Excel file and I saved it as a CSV thinking I had to do that in order to use the LabVIEW file functions?

If you could shed some light and set me straight be very appreciative?

0 Kudos
Message 5 of 6
(235 Views)

@LED47 wrote:

Well I have to admit I'm not that proficient in understanding the Excel-.CSV relationship.

Yes I started out with an Excel file and I saved it as a CSV thinking I had to do that in order to use the LabVIEW file functions?


LabVIEW supports some Microsoft formats (word excel, etc) with the report generation toolkit. Some of the express file IOs also support various file types.

 

It is typically much cleaner to write flat delimited text files. Some people actually cheat and give them a fake .xlsx file extension and all that does is force the OS to open it with excel when you later double-click it in the file explorer. Excel is often smart enough to recognize the actual format and read it in correctly. Problems occur you you would then save it in excel format because you would no longer be able to read it inside LabVIEW the same way as before the conversion. (Of course there are ways to make reading excel files easier too! 😄 )

0 Kudos
Message 6 of 6
(223 Views)