08-28-2018 10:52 AM
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.
08-28-2018 11:07 AM - edited 08-28-2018 11:10 AM
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…)
08-28-2018 11:09 AM
Try reading the text file with the "Read Delimited Spreadsheet.vi" and set the delimiter to a comma.
08-28-2018 12:16 PM
@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.
08-28-2018 12:34 PM
I think the csv is already in comma delimited format. Is there a function that allows me to rename it to a csv extension??
08-28-2018 12:36 PM
This is what I want to do.
08-28-2018 01:27 PM
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?
08-28-2018 02:51 PM
This code will convert your data file into a format that Excel will read correctly.
08-28-2018 04:58 PM
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??
08-28-2018 07:23 PM
@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.