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 

simplified csv operations.
Goto page Previous  1, 2, 3, 4
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
cLue
Guest





PostPosted: Tue Jan 20, 2009 10:01 pm    Post subject: Reply with quote

First of all I have to thank you for the great work - very helpful!

But I tested the script and identified several errors:

1) CSV_writeCell and XLS_writeCell do not change the var. __line%row%
- Statement should be : __line%row% := regExReplace(__line%row%, __matrix%row%_%column%, Format4CSV(value))

2) To have all changes reflected in the .csv using finalize_CSV the r_updated value should be set to false using r_updated = false (not := false)
or the if statement within the finalize_CSV should be changed to: if(r_updated = false) (not: r_update = "false")

Regards
Back to top
cLue
Guest





PostPosted: Tue Jan 20, 2009 11:18 pm    Post subject: Reply with quote

I built functions for adding or removing rows (quick and dirty as I'm in a hurry):

Code:
CSV_addrow(value) { ;"b1,b2,b3"
   global

   loop parse, value, %r2_delimiter%
      __matrix%r_row%_%A_Index% := regExReplace(A_LoopField, "\R?$") ;%
    
   __line%r_row% := value
      
   r_row := r_row + 1
   CSV_totalRows()
   
   r_updated := false
}

CSV_deleterow(row) {
   global
      
   if (r_header)
      row ++
   
   Loop % r_lastRow - row ;%
   {
      t_row := row + A_Index - 1
      n_row := t_row + 1
      
      __line%t_row% := __line%n_row%
      
      loop r_col
         __matrix%t_row%_%A_Index% := __matrix%n_row%_%A_Index%
   }
      
   r_row := r_row - 1
   CSV_totalRows()
   
   r_updated := false
}


Maybe somebody will clean it up a bit Wink
cLue
[/b]
Back to top
trueski



Joined: 08 Apr 2008
Posts: 92
Location: Minnesota, USA

PostPosted: Tue Mar 31, 2009 10:31 pm    Post subject: Reply with quote

Quote:
I built functions for adding or removing rows (quick and dirty as I'm in a hurry):


Remove function works fine once, but when attempting to delete multiple rows the entire array will be erased or rows become duplictated, or nothing happens at all
_________________
-trueski-
Back to top
View user's profile Send private message
neXt



Joined: 18 Mar 2007
Posts: 505

PostPosted: Tue Jan 05, 2010 2:49 am    Post subject: Reply with quote

I haven't done any debugging with writing values since i don't ever need to use them, makes me sad how broken these functions are Embarassed .

Ok, i spent a few hours trying to read my own code Laughing and made some fixes with writing and finalizing functions. The only problem is it's not writing the very last line in csv file.
I'll try to fix that and implement suggested changes and functions in the original code/post in a short period of time.

P.S. Original post updated. I ran a few quick test and it seems to be writing values and saving copies just fine now.
P.P.S. There is one more bug that i have no idea how to fix as of now. If Any row contains duplicate data in separate columns and you attempt to overwrite only the later value, both will be overwritten. For instance if your row contains "1,2,3,1,4" and you need to overwrite only the fourth column, not the first one, function will replace both Embarassed .
_________________
simplified csv - easy way to handle csv files.
Back to top
View user's profile Send private message
SoLong&Thx4AllTheFish



Joined: 27 May 2007
Posts: 4999

PostPosted: Tue Jan 05, 2010 7:39 am    Post subject: Reply with quote

@neXt you did see trueskis' version here http://www.autohotkey.com/forum/topic42843.html Question
_________________
AHK Wiki FAQ
TF : Text files & strings lib, TF Forum
Back to top
View user's profile Send private message
kdoske



Joined: 17 Dec 2008
Posts: 80

PostPosted: Sun Mar 21, 2010 3:00 am    Post subject: Reply with quote

I actually updated trueskis libary even more by adding more features and making it more reliable. It can be seen here:

Updated CSV Library - http://www.autohotkey.com/forum/viewtopic.php?p=341189#341189
Back to top
View user's profile Send private message
neodrac23



Joined: 16 Oct 2011
Posts: 21
Location: Charlotte

PostPosted: Sun Oct 16, 2011 1:34 am    Post subject: Help for a noob Reply with quote

I just want to search a xls file, search by variable and return row to separate variable.
this is simple in perl, grep... but it's killing me in ahk, HELP Please?
Embarassed
Back to top
View user's profile Send private message
Guest






PostPosted: Sun Oct 16, 2011 7:58 am    Post subject: Re: Help for a noob Reply with quote

neodrac23 wrote:
I just want to search a xls file, search by variable and return row to separate variable.

a) you are using the wrong library (if you work with CSV the kdoske one above is better OR use the table data library by VxE)
b) if you work with actual XLS files none of the CSV/TABLE libraries are of use as they don't work with binary files, you need COM like http://www.autohotkey.com/forum/topic70421.html&highlight=excel+com
So, try again Wink
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4
Page 4 of 4

 
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