|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Extract name/value pairs from text file into csv
Hi,
I need to extract the parameters from an input file (ini) and put them into a spreadsheet (output file) for reporting and analysis. My requirement is: Input file: parameters.ini (text) [SECTION 1] Name1 = 'value1' Name2 = 'value2' [SECTION 2] Name3 = 'value3' Name3 = 'value4' Output file: parameters.csv (text/csv) SECTION1, Name1, value1 SECTION1, Name2, value2 SECTION2, Name3, value3 SECTION2, Name4, value4 Does anyone know how to do this in a batch file (preferred) or shell script? Thanks, Andrew |
|
#2
|
||||
|
||||
|
Quote:
One idea would be to define a variable whose value initially is SECTION1. As you progress through the lines, each time you find one that matches the pattern NAMEx=y, then output a line that has the value of the variable followed by a colon followed by NAMEx followed by a colon followed by y Then each time you find a line that matches the pattern [SECTIONx], you can change the value of the variable. |
![]() |
| Viewing: Dev Shed Forums > Web Site Management > Scripts > Extract name/value pairs from text file into csv |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|