MaCgyver Posted March 7, 2006 Share Posted March 7, 2006 Well I am looking to do the following. In a specific .csv file I want to sort out two specific types of data. One particular column has either XX or YY in the cells. My boss wants me to sort them out, so that we get totals for XX and YY in a report. The .CSV appends data to it through the day and that was done with the autoit and the help of BigDod or was it BidDod? . Anyway this would be easy to do within the file, but the users can't have access to manipulate data, so I have to find another method. I am working with the file to see if can put sometype of protection within the worksheet that would allow them to sort and get the totals they are looking for, but not edit the cells. I haven't had to much luck with that idea and my boss probably won't go for it. So before I go work on it somemore I wanted to ask the autoit pros. If autoit could search for all the ROWS that have XX in the first column and import it into something else and the same for all the ROWS that have YY and provide totals for each than my task would be done. I've used autoit on a few other tasks for this project that I am on and it has worked out perfectly. I don't expect Autoit to do everything and if can't do this task I still believe its a powerful software. If it could help me with this task that would just be like have an early Christmas or something. cliff note: import specific data from a .csv file into some type of grid that cannot be edited by users Link to comment Share on other sites More sharing options...
MaCgyver Posted March 7, 2006 Author Share Posted March 7, 2006 no reply yet... well i'm looking through autoit help..maybe i can find something. Link to comment Share on other sites More sharing options...
w0uter Posted March 7, 2006 Share Posted March 7, 2006 take a look at FileRead() & String*() My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
MaCgyver Posted March 7, 2006 Author Share Posted March 7, 2006 take a look at FileRead() & String*()will do. thanks! Link to comment Share on other sites More sharing options...
CyberSlug Posted March 7, 2006 Share Posted March 7, 2006 (edited) Assuming your data looks likeXX,100YY,200XX,300YY,500XX,400XX,100Global $xx_count = 0, $yy_count = 0 $file = FileOpen("example.csv", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in lines of text until the EOF is reached While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop $data = StringSplit($line, ",") If $data[1] = "XX" Then $xx_count = $xx_count + $data[2] Else; I suppose $data[1] = "YY" $yy_count = $yy_count + $data[2] EndIf Wend MsgBox(0x1000,"Output", "XX SUM is " & $xx_count) MsgBox(0x1000,"Output", "YY SUM is " & $yy_count) FileClose($file) Edited March 7, 2006 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
MaCgyver Posted March 7, 2006 Author Share Posted March 7, 2006 (edited) you made the right assumption. there are more columns, but i will check out what you put together. i really appreciate the help. it worked like a charm. i will make a few changes in the script to test on the actual file and have the output sent to another file. once i have it done i would like to make a small contribution to this site and something to you,but i dont know if that is allowed on this site. maybe one of the admins can let me know and let me know where to send my contribution to the site. Edited March 7, 2006 by MaCgyver Link to comment Share on other sites More sharing options...
MaCgyver Posted March 7, 2006 Author Share Posted March 7, 2006 you made the right assumption. there are more columns, but i will check out what you put together. i really appreciate the help. it worked like a charm. i will make a few changes in the script to test on the actual file and have the output sent to another file. once i have it done i would like to make a small contribution to this site and something to you,but i dont know if that is allowed on this site. maybe one of the admins can let me know and let me know where to send my contribution to the site. Global $PI_count = 0, $PO_count = 0 $file = FileOpen('GLDAILY.CSV', 0) $file2 = FileOpen('gldailyPI.csv',1) $file3 = FileOpen('gldailyPO.csv',1) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to READ file.") Exit EndIf ; Read in lines of text until the EOF is reached While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop $data = StringSplit($line, ",") If $data[2] = "PI" Then $PI_count = $PI_count + $data[7] FileWriteLine($file2,$line) Else; It's assumed that $data[2] = "PO" $PO_count = $PO_count + $data[7] FileWriteLine($file3,$line) EndIf Wend ;MsgBox(0x1000,"Output", "PI SUM is " & $PI_count) ;MsgBox(0x1000,"Output", "PO SUM is " & $PO_count) FileClose($file) FileClose($file2) FileClose($file3) ;Can I use FileClose($file,file2,$file3) instead? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now