From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
08-23-2015 10:08 AM - edited 08-23-2015 10:16 AM
Hi i m new user of labwindows. i want to read columns from text file and then save some columns in another file. for example a text file with 11 columns are
a b c d e f g h i j k
1 2 3 4 5 6 7 8 9 8 2
so i have 11 columns and 11 rows. now i just want to read columns from text file and then want to save two columns in someother file. for example column 4 and 5. kindly brief me in detail
08-23-2015 12:26 PM
kindly rply me soon i m waiting for ur replys
08-23-2015 01:49 PM
Given that there is not a unique command that does what you want, you can build up you solution splitting it into two tasks:
-read data from file
-extract data and save to a new file
Each task can be solutioned in more ways: as a general suggestion you can use FileToArray to read the file and get your data.
You can then use functions from Formatting and I/O Library to save data to a new file.
As an alternative consider using File I/O for the first task also: Open file, Read Line (as I understand you have a text file that can be read line by line) to read the file; Scan to extract only the columns you want from the line.
08-23-2015 09:22 PM
sir Roberto thnx for your reply sir i still cant understad how to solve my problem i m attaching text file for an example kindly give me the code how to extract 3rd and 5th column from that file and saving another file. i shall be very thankfull to u sir. i never work before that on labwindows so initialy help me in more detail plz.
08-23-2015 09:30 PM
sir Roberto i i read the file the will be stored in a single array as a whole then how can i split the particular column and save it into the new file. i m confuse sir kindly help me i saw that u r a supporting guy to all people i love programing i will work hard but in start i need great help sir
08-24-2015 02:09 AM - edited 08-24-2015 02:12 AM
Unfortunately I am on vacations now with no PC so I can only give you some conceptual framework for you to elaborate on. The help for the commands I list will be helpful; I suggest you also look in the examples supplied (search by help 》find examples function) and/or look in the forums.
The framework you can start with is the following: not the most efficient but simple an fast enough for small files (say < 1 Mb).
OpenFile (source file, Read only) OpenFile (destination file, write only) Read one line from source if you have heading row Create proper line in destination if you want heading row while (1) { r = ReadLine (source file, put into a buffer) Test 'r' for end-of-file condition: break out the loop Scan (buffer, look in command help to skip unwanted fields and extract only desired ones) e.g. Scan (buffer, "%2d[d]%d%d[d]%d", &var1, &var2) will extract 3rd and 5th field sprintf (create the output string in the format you want WriteLine (destination file) } CloseFile (source) CloseFile (destination)
08-24-2015 11:11 AM
sir kindly explain me scan function in detail i m also confused in using that function
08-24-2015 12:43 PM
The best I can offer you at present is the help on the function, which includes several examples on how to use it in various scenarios.