04-11-2008 05:09 PM
Hi, folks,
I am transferring a text file to spreadsheet.
The file has a lot of junk words has to be throw away, this part is easy, the challenge is to keep the file name as header and two columns of data, then append another file name/data to different columns.
I just get started to use Labview, quickly enough I have no problem to append data to the end of the spreadsheet (I save spreadsheet called test_output on desktop) but no success wahtsoever to write into different columns.
I attached my code and the text file.
Any help are greatly appreciated!!!
Ray
04-11-2008 10:23 PM
04-13-2008 07:52 PM
Hi, Thanks for looking into my question, putty_text is the input text file. My code will produce a text file like the first attached below (called text_output),
What I hoped it to be is the second one (called text_expected_output).
You are right, my current output is not a spreadsheet, rather a text file which can be read by Excel, this's fine to me at this moment as long as data
can be appended to different column in one single file. The for loop runs three time in the code and this is also only for the illustration purpose.
04-13-2008 09:17 PM
It looks like your VI is only designed to run once on a single file. I am not sure why the for loop has N=3. Since you are looking to add a new file into adjacent columns, you won't be able to use the append to file, or write to the file at all within the loop. That's because the file gets written to at the end thus making it longer. You want your file to basically expand to the right where each line would have need data added to it before a linefeed character.
You will need to be able to select all 3 files in a loop and let the code process each one and create a string array. On each iteration, you will need to append a 2-D array to another 2-D array using the build array function. It may get tricky and you may need to use transpose array functions to make sure the final form of the array gets build the way you want.
Once the loops are done iterating, only then can you write your string array out to the file.
04-16-2008 02:45 PM
Thanks for hint, my code runs successfully now, the tricky
part is to use transpose array twice, one inside the loop before building array
function, another outside the loop before writing to the file.
Why the for loop has N=3 is not my concern, it probably should be, cause I actually don’t know how to quit the for loop when searching the text file to the end. But setting N equal to a larger number seems just works fine.