home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.msdos.batch.nt      Fun with Windows NT batch files      68,980 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 67,131 of 68,980   
   JJ to rjobaan@gmail.com   
   Re: Read just first line from file   
   30 Jan 18 04:11:23   
   
   From: jj4public@vfemail.net   
      
   On Mon, 29 Jan 2018 01:39:28 -0800 (PST), rjobaan@gmail.com wrote:   
   > How can a change my first line of a csv file   
   > the first line of my test.csv file looks like   
   >   
   > Country,region,Place   
   > Netherlands,Utrecht,Soest   
   >   
   > And i want to add a underscore into first line only   
   > so files looks like   
   >   
   > _Country,_region_Place   
   > Netherlands,Utrecht,Soest   
   >   
   > how to do that?   
      
   Batch file can't actually edit the line(s) in text files. It can only   
   overwrite or append the file contents.   
      
   So, use FOR /F to retrieve the lines and write them into a new file. Change   
   the line when it's the first one, and leave the rest unchanged. But since   
   you need to insert an underscore onto each header column of the CSV file,   
   the lines would need to be parsed and be split into columns using "," as the   
   delimiter. Each line would then need to be rebuilt by reinserting the ","   
   column separators before writing them out to the output file. Once all of   
   the lines are processed, replace the original CSV file with the changed one.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca