 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
jagpanzer
Joined: 24 Jan 2006 Posts: 10 Location: Florida
|
Posted: Thu Jan 29, 2009 2:07 am Post subject: CSV Help - Use AHK to edit 2nd line of CSV |
|
|
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 |
|
 |
BoBoł Guest
|
Posted: Thu Jan 29, 2009 12:34 pm Post subject: |
|
|
| 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.  |
|
| Back to top |
|
 |
BoBoł Guest
|
|
| Back to top |
|
 |
jagpanzer
Joined: 24 Jan 2006 Posts: 10 Location: Florida
|
Posted: Thu Jan 29, 2009 5:23 pm Post subject: |
|
|
Awesome!!
Thanks BoBo - that gave me the nudge I needed to get this working. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|