AutoHotkey Community

It is currently May 26th, 2012, 2:47 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: January 29th, 2009, 3:07 am 
Offline

Joined: January 24th, 2006, 6:04 am
Posts: 10
Location: Florida
Hiya,

I need some help coming up with the code to edit the second line of a csv file.

What I want to happen is to run the script, and be prompted to enter in 2 values. These values would be placed in the first and second columns of the CSV in the second row. The first row, and the entries in the third and fourth columns in the second row would always remain the same.

Example CSV file (the Variable1 and Variable2 entries are what I want to get prompted for):
header1,header2,header3,header4
Variable1,Variable2,third,fourth

I tried the code here ( http://www.autohotkey.com/forum/topic32833.html) in several variations but it always seemed to erase the last row in my CSV rather than editing it.

I'm pretty sure there has to be a simple solution to this, but I'm having some trouble since I'm a newb! Any help would be appreciated.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 29th, 2009, 1:34 pm 
Code:
FileRead, FileContent, C:\MyDirectory\My.csv
FileReadLine, ToReplace, C:\MyDirectory\My.csv, 2
StringReplace, FileContent, FileContent, %ToReplace%, WithThat1
StringReplace, FileContent, FileContent, %ToReplace%, WithThat2
FileCopy, C:\MyDirectory\My.csv, C:\MyDirectory\My.bak
FileAppend, %FileContent%, C:\MyDirectory\My.csv
Noobish attempt. :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 29th, 2009, 1:38 pm 
Might be of interest too: [StringMod() String Manipulation - Enhanced by PhiLho / Titan] :wink:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 29th, 2009, 6:23 pm 
Offline

Joined: January 24th, 2006, 6:04 am
Posts: 10
Location: Florida
Awesome!!

Thanks BoBo - that gave me the nudge I needed to get this working.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: G. Sperotto, Google [Bot], patgenn123, Yahoo [Bot] and 17 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group