AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CSV Help - Use AHK to edit 2nd line of CSV

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
jagpanzer



Joined: 24 Jan 2006
Posts: 10
Location: Florida

PostPosted: Thu Jan 29, 2009 2:07 am    Post subject: CSV Help - Use AHK to edit 2nd line of CSV Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
BoBoł
Guest





PostPosted: Thu Jan 29, 2009 12:34 pm    Post subject: Reply with quote

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. Smile
Back to top
BoBoł
Guest





PostPosted: Thu Jan 29, 2009 12:38 pm    Post subject: Reply with quote

Might be of interest too: [StringMod() String Manipulation - Enhanced by PhiLho / Titan] Wink
Back to top
jagpanzer



Joined: 24 Jan 2006
Posts: 10
Location: Florida

PostPosted: Thu Jan 29, 2009 5:23 pm    Post subject: Reply with quote

Awesome!!

Thanks BoBo - that gave me the nudge I needed to get this working.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group