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
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
neXt



Joined: 18 Mar 2007
Posts: 463

PostPosted: Wed Jun 25, 2008 4:18 pm    Post subject: Reply with quote

It's really laggy and sorts only numbers i guess, i need to tune it up Embarassed .
I tested it on this file. Sorted by column 2.
Quote:
Req on File,W.O.No.,Cli,Loc #,Lev,Description
*R*,431368,CWC,80109,3,SALES FLOOR CLEANING
*R*,431563,CWC,80110,3,SALES FLOOR CLEANING
*R*,431394,CWC,80111,3,SALES FLOOR CLEANING
*R*,431632,CWC,80102,A1,LEVEL A1 - WINDOW CLEANING
*R*,432098,CWC,80103,A1,LEVEL A1 - WINDOW CLEANING
*R*,431907,CWC,80104,A1,LEVEL A1 - WINDOW CLEANING
*R*,432024,CWC,80105,A1,LEVEL A1 - WINDOW CLEANING
*R*,431455,CWC,80106,A1,LEVEL A1 - WINDOW CLEANING
*R*,431571,CWC,80107,A1,LEVEL A1 - WINDOW CLEANING
*R*,431397,CWC,80108,A1,LEVEL A1 - WINDOW CLEANING
*R*,431369,CWC,80109,A1,LEVEL A1 - WINDOW CLEANING
*R*,431564,CWC,80110,A1,LEVEL A1 - WINDOW CLEANING
*R*,431395,CWC,80111,A1,LEVEL A1 - WINDOW CLEANING
*R*,431633,CWC,80102,A2,LEVEL A2 - WINDOW CLEANING
*R*,432099,CWC,80103,A2,LEVEL A2 - WINDOW CLEANING
*R*,431908,CWC,80104,A2,LEVEL A2 - WINDOW CLEANING
*R*,432025,CWC,80105,A2,LEVEL A2 - WINDOW CLEANING
*R*,431456,CWC,80106,A2,LEVEL A2 - WINDOW CLEANING
*R*,431572,CWC,80107,A2,LEVEL A2 - WINDOW CLEANING
*R*,431398,CWC,80108,A2,LEVEL A2 - WINDOW CLEANING
*R*,431370,CWC,80109,A2,LEVEL A2 - WINDOW CLEANING
*R*,431565,CWC,80110,A2,LEVEL A2 - WINDOW CLEANING


It needs work
_________________
simplified csv - easy way to handle csv files.
Back to top
View user's profile Send private message
Krogdor



Joined: 18 Apr 2008
Posts: 1145
Location: The Interwebs

PostPosted: Wed Jun 25, 2008 6:26 pm    Post subject: Reply with quote

A comment about the sort... Sorry if there's something I'm not seeing again.

Code:
CSV_sort(column=1, order="asc") {
   global

   if (order = "desc")
      order = R
   
   if (column = 1)
      Sort r_file, N %order%

Unless the user sets order to "desc", isn't the Sort going to receive "N asc" as options? I don't think "asc" is a valid option Mad
Back to top
View user's profile Send private message AIM Address
neXt



Joined: 18 Mar 2007
Posts: 463

PostPosted: Thu Jun 26, 2008 5:51 pm    Post subject: Reply with quote

I made some fixes to sort function, it works much better now.
_________________
simplified csv - easy way to handle csv files.
Back to top
View user's profile Send private message
WankerMan



Joined: 20 Jul 2006
Posts: 10

PostPosted: Mon Jul 28, 2008 7:28 pm    Post subject: Error on Line 21. Line Text:" Error: Bad default value. Reply with quote

Hello all, and especially HugoV

I am interested in using your function but I get an error when I try.
The error is : Error on Line 21. Line Text:" Error: Bad default value.

The code is :
Code:
set_CSV(file, header=0, delimiter=",")


Do any of you know why this is happening? Is there a newer version of this function available somewhere ?

Let me know,

Cheers,

WankerMan Rolling Eyes [/img]
Back to top
View user's profile Send private message MSN Messenger
neXt



Joined: 18 Mar 2007
Posts: 463

PostPosted: Mon Jul 28, 2008 9:12 pm    Post subject: Reply with quote

If you simply trying to specify a file, here's how it's done:
Code:
set_CSV("example.csv")

_________________
simplified csv - easy way to handle csv files.
Back to top
View user's profile Send private message
WankerMan



Joined: 20 Jul 2006
Posts: 10

PostPosted: Thu Jul 31, 2008 4:07 pm    Post subject: Jumping the gun. Reply with quote

Thanks HugoV,

I panicked to quickly. All is good. Actually more than good. This function is freakn' sweet. I can't believe how much time it has saved me.

Cheers all,

Curtis Mr. Green
Back to top
View user's profile Send private message MSN Messenger
neXt



Joined: 18 Mar 2007
Posts: 463

PostPosted: Mon Aug 04, 2008 4:19 pm    Post subject: Reply with quote

updated, added XLS_readCell and XLS_writeCell
_________________
simplified csv - easy way to handle csv files.
Back to top
View user's profile Send private message
HugoV



Joined: 27 May 2007
Posts: 650

PostPosted: Mon Aug 04, 2008 6:58 pm    Post subject: Reply with quote

ALso I see you "fixed" the finalize_CSV to write in one fileappend instead of
per CSV line That will improve the speed quite a bit...
_________________
When parsing a CSV file use Loop, parse, Inputvar, CSV!
Back to top
View user's profile Send private message
neXt



Joined: 18 Mar 2007
Posts: 463

PostPosted: Mon Aug 04, 2008 7:02 pm    Post subject: Reply with quote

Yeah, there are quite a few changes in the code Very Happy
_________________
simplified csv - easy way to handle csv files.
Back to top
View user's profile Send private message
CannedCheese



Joined: 21 May 2008
Posts: 85

PostPosted: Thu Aug 07, 2008 5:19 pm    Post subject: Reply with quote

Small point, but wouldn't it make sense to rename all of those functions not beginning as CSV_Something (like finalize_CSV) to begin with CSV (e.g., CSV_Finalize) so that this can be included as a part of a library in \lib ?
Back to top
View user's profile Send private message
neXt



Joined: 18 Mar 2007
Posts: 463

PostPosted: Thu Aug 07, 2008 6:01 pm    Post subject: Reply with quote

Yes, it would make more sense i guess. I did it like that to draw attention since those 2 functions are important, but it looks like they create more confusion rather than serve their purpose. I'll change that when i'll come up with a new update.
_________________
simplified csv - easy way to handle csv files.
Back to top
View user's profile Send private message
CannedCheese



Joined: 21 May 2008
Posts: 85

PostPosted: Thu Aug 07, 2008 6:26 pm    Post subject: Reply with quote

You could call it CSV_SET and CSV_FINALIZE to add emphasis (i.e., they're the only functions with all CAPS).

This looks sweet btw.
Back to top
View user's profile Send private message
truevis



Joined: 08 Sep 2008
Posts: 10

PostPosted: Wed Sep 10, 2008 6:55 pm    Post subject: CSV_search Reply with quote

How about this function to add to it? It returns the location if the RegEx matches, whereas the CSV_Find only returns if the whole cell matches. Please check its validity.

Code:
CSV_search(value, row=0, column=0, offset_x=0, offset_y=0) {
   global

   i = 0
   ;full search
   if (row = 0 && column = 0) {
      loop %r_lastRow% {
         i++
         loop %r_lastCol% {
            if (0 < RegExMatch(__matrix%i%_%A_Index%, value))
               return % i + offset_x . "," . A_Index + offset_y                ;%
         }
      }
   }

   ;search specified row
   if (row != 0 && column = 0) {
      loop %r_lastCol% {
         if  (0 < RegExMatch(__matrix%row%_%A_Index%, value))
            return % A_Index + offset_y                                         ;%
      }
   }

   ;search specified column
   if (row = 0 && column != 0) {
      loop %r_lastRow% {
         if (0 < RegExMatch(__matrix%A_Index%_%column%, value))
            return % A_Index + offset_x                                         ;%
      }
   }
return false
}
Back to top
View user's profile Send private message Visit poster's website
HugoV



Joined: 27 May 2007
Posts: 650

PostPosted: Thu Sep 11, 2008 4:37 pm    Post subject: Reply with quote

In the ask for help there is a question/bug, if I run his example I indeed
get an empty file, it gets better if I add the fullpath to the file and
also "1" in the finalize. I did notice another problem, the _copy file
was missing the last row entirely and also the new value of the
1 1 cell wasn't there.
_________________
When parsing a CSV file use Loop, parse, Inputvar, CSV!
Back to top
View user's profile Send private message
kiropes



Joined: 21 Mar 2007
Posts: 35
Location: Italy

PostPosted: Thu Sep 11, 2008 4:55 pm    Post subject: Reply with quote

another bug is in CSV_sort

the new file is written without space delimiter
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3
Page 3 of 3

 
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