LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Text File

Hey everyone, I am trying to read a text document. I want to read the text document and put it into a excel file. The thing is I want to split up everything via commas and put them in individual columns. I would like to use the comma as a delimiter. However when it is entered into the excel file, nothing gets split. This is the code I am using to split everything up. 

0 Kudos
Message 1 of 11
(3,551 Views)

Hi Rayzab,

 

I would like to use the comma as a delimiter.

You use this delimiter with the SpreadsheetStringToArray function, but not with the WriteDelimitedFile function.

You need to set a delimiter here too - Excel doesn't like (apparently) empty strings as delimiter! Depending on the file suffix (and regional options) Excel likes tabs, semicolons or commas…

 

You also should attach VIs (or real snippets) instead of just images: we cannot debug images with LabVIEW!

And using AutoCleanup before posting code is always a good idea! (It's also a good idea to make the display mode indicator visible with every string constant…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 11
(3,545 Views)

Try reading the text file with the "Read Delimited Spreadsheet.vi" and set the delimiter to a comma.

 

douCapture.PNG

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 3 of 11
(3,542 Views)

@Rayzab wrote:

Hey everyone, I am trying to read a text document. I want to read the text document and put it into a excel file. The thing is I want to split up everything via commas and put them in individual columns. I would like to use the comma as a delimiter. However when it is entered into the excel file, nothing gets split. This is the code I am using to split everything up. 


Is the text document already in a comma delimited format?  If so, just rename it to have a csv extension and Excel will open it up just fine.

 

If that is not the case, you might want to post an example text file and a corresponding output file you would like.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 11
(3,503 Views)

I think the csv is already in comma delimited format. Is there a function that allows me to rename it to a csv extension?? 

0 Kudos
Message 5 of 11
(3,499 Views)

This is what I want to do.

0 Kudos
Message 6 of 11
(3,498 Views)

Move File in the File I/O >>  Advanced File functions palette.

 

One issue I see is that your .txt document has quotes around an entire row of data.  If you import that, you'll get a quote at the beginning of your first column value, and a quote at the end of your last column value.

 

What program is generating this text file?

Message 7 of 11
(3,474 Views)

This code will convert your data file into a format that Excel will read correctly.

cf.png

"If you weren't supposed to push it, it wouldn't be a button."
Message 8 of 11
(3,453 Views)

The text file is already made. Due to confidentiality agreements I cannot share it. However its a huge block of text. The problem is there the delimiter won't be read when there is a quotation around the sentence, Is there anyway to fix this??

0 Kudos
Message 9 of 11
(3,440 Views)

@Rayzab wrote:

The text file is already made. Due to confidentiality agreements I cannot share it. However its a huge block of text. The problem is there the delimiter won't be read when there is a quotation around the sentence, Is there anyway to fix this??


The code snippet I provided fixes it.  Try it.

"If you weren't supposed to push it, it wouldn't be a button."
Message 10 of 11
(3,430 Views)