Saved Bookmarks
| 1. |
Solve : read file and store in a variable? |
|
Answer» HELLO I wanted some help to perform the following TASK 1.read a .txt file 2.read a PARTICULAR COLUMN from an excel sheet (say all the contents from 2 column ) 3.store the contents in a variable with a white space as a separator or a (,) as a separator The content of the test file and the excel sheet will look like 8889.0 8889.1 8889.2 8889.3 8889.99 any help in this regards will be highly appreciated ok to read the excel sheet isnt possible in batch nor in DOS but it is possible in VBthanks instead of a excel sheet can we read a text file u can use .CSV its readable both by excel and DOS will Read help in this case for /F "tokens=1 delims== " %%i In (sample.txt) Do set latest_file= %%i set newval= " "+ latest_file echo values are %latest_file% i am using this ? but this stored only the latest value, i need to store all the values to latest_file or newval if you want to read excel, you might want to learn some vbscript. Code: [Select] Set objExcel = CreateObject("Excel.Application") Set objWorkbook = objExcel.Workbooks.Open _ ("C:\test\test.xls") intRow = 1 Do Until objExcel.Cells(intRow,1).Value = "" Wscript.Echo "Col 1: " & objExcel.Cells(intRow, 1).Value Wscript.Echo "Col 2: " & objExcel.Cells(intRow, 2).Value Wscript.Echo "Col 3: " & objExcel.Cells(intRow, 3).Value intRow = intRow + 1 Loop objExcel.Quit Thank you very much, this helped |
|