// read a CSV works perfect
// To see whats inside the file ( its no secrect its my pricelist )
// ->>>>> http://www.ohilger.de/eue.csv
CSVFileToArray>C:\Users\username\Desktop\eue.csv,arrCSV
// i can read all dimensions of the array like
// Let>info=arrCSV_1_1
// MDL>info
// but if i want to count the Elements of the array it always say
//
ArrayCount>arrCSV,Numinfo
MDL>Numinfo
// What is wrong with me and my script ....??
How Arraycount after CSVFileToArray
Moderators: Dorian (MJT support), JRL
-
- Pro Scripter
- Posts: 60
- Joined: Tue Dec 22, 2009 9:51 am
- Location: Mannheim ( Germany )
- Contact:
How Arraycount after CSVFileToArray
Oliver Hilger Mannheim
alias Olllllliii
alias Olllllliii
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Nothing wrong with you. ArrayCount can only work with single dimension arrays. CSV files are multi-dimensional.
ArrayCount can work with ONE of the dimensions.
The first dimension of the array produced by CSVFileToArray is the row. You could use ArrayCount on that to see how many fields there in the row:
ArrayCount>arrCSV_1
But you don't need to. CSVFileToArray returns a count for each row (each dimension) and also the total number of rows anyway.
ArrayCount can work with ONE of the dimensions.
The first dimension of the array produced by CSVFileToArray is the row. You could use ArrayCount on that to see how many fields there in the row:
ArrayCount>arrCSV_1
But you don't need to. CSVFileToArray returns a count for each row (each dimension) and also the total number of rows anyway.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
-
- Pro Scripter
- Posts: 60
- Joined: Tue Dec 22, 2009 9:51 am
- Location: Mannheim ( Germany )
- Contact:
Thank you Marcus ,
so i wrote a small script to get the lines of the data .
Here is the solution. It is much faster than the old version ..
// The old version is very slow on big files
Let>count=0
Let>filename=c:\daten4.txt
Label>Start
Let>count=count+1
ReadLn>filename,count,line
If>line=##EOF##,end
Goto>Start
Label>end
MessageModal>Number of lines in file = %count%
// end old version
// Very much faster to count lines
Kind regards
Oliver
so i wrote a small script to get the lines of the data .
Here is the solution. It is much faster than the old version ..
// The old version is very slow on big files
Let>count=0
Let>filename=c:\daten4.txt
Label>Start
Let>count=count+1
ReadLn>filename,count,line
If>line=##EOF##,end
Goto>Start
Label>end
MessageModal>Number of lines in file = %count%
// end old version
// Very much faster to count lines
Code: Select all
Let>count=1
Let>filename=C:\Users\Steffen\Desktop\eue.csv
CSVFileToArray>filename,arrCSV
Label>Start
Let>count=count+1
Let>data=arrCSV_%count%_1
Midstr>data,1,6,out
If>out={"arrCSV"},end
Goto>Start
Label>end
MessageModal>you have %count% lines in your file
Oliver
Oliver Hilger Mannheim
alias Olllllliii
alias Olllllliii
Hi olllllliii,
Thanks for sharing your solution. I wonder if that is the fastest way possible to find the number of lines in a file?
If anyone has another way they think might be faster, please post and share it with us all.
Your post reminded me of a similar problem I had only I had to very quickly count the number of lines pasted into a memo field on a dialog in a compiled MS script. Check out the link below and maybe you can make use of the techniques there as well:
[Bounty Won] Text Blob Line Counter Speed Challenge
http://www.mjtnet.com/forum/post23762.html#23762
Take care
Thanks for sharing your solution. I wonder if that is the fastest way possible to find the number of lines in a file?
If anyone has another way they think might be faster, please post and share it with us all.
Your post reminded me of a similar problem I had only I had to very quickly count the number of lines pasted into a memo field on a dialog in a compiled MS script. Check out the link below and maybe you can make use of the techniques there as well:
[Bounty Won] Text Blob Line Counter Speed Challenge
http://www.mjtnet.com/forum/post23762.html#23762
Take care
jpuziano
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Here are 2 quick methods to count files, one uses Separate the other uses ReadLn. You be the judge.jpuziano wrote:Hi olllllliii,
Thanks for sharing your solution. I wonder if that is the fastest way possible to find the number of lines in a file?
If anyone has another way they think might be faster, please post and share it with us all.
Your post reminded me of a similar problem I had only I had to very quickly count the number of lines pasted into a memo field on a dialog in a compiled MS script. Check out the link below and maybe you can make use of the techniques there as well:
[Bounty Won] Text Blob Line Counter Speed Challenge
http://www.mjtnet.com/forum/post23762.html#23762
Take care
Code: Select all
DEL>%TEMP_DIR%MS Test Text Document.txt
EXP>MS_TEST_TEXT_DOCUMENT.TXT_DATA,%TEMP_DIR%MS Test Text Document.txt
//Method 1
Timer>StartTimer
ReadFile>%TEMP_DIR%MS Test Text Document.txt,Lines
Separate>Lines,CRLF,NumLines
Timer>EndTimer
LET>ElapsedTime={(%EndTimer%-%StartTimer%)/1000}
Let>Method1=Lines: %NumLines_count%%CRLF%Time: %ElapsedTime% sec
//Method 2
Let>k=0
Timer>StartTimer
Repeat>k
Add>k,1
ReadLn>%TEMP_DIR%MS Test Text Document.txt,k,res
If>res=##EOF##
Sub>k,1
Goto>Done
ENDIF
Until>k,0
Label>Done
Timer>EndTimer
LET>ElapsedTime={(%EndTimer%-%StartTimer%)/1000}
DEL>%TEMP_DIR%MS Test Text Document.txt
Let>Method2=Lines: %k%%CRLF%Time: %ElapsedTime% sec
mdl>Method 1 Result:%CRLF%%Method1%%CRLF%Method 2 Result:%CRLF%%Method2%
/*
MS_TEST_TEXT_DOCUMENT.TXT_DATA:
310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310
D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A
310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310
D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A
310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310
D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A
310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310
D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A
310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310
D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A
310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310
D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A
310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310
D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A
310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310
D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A
310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310
D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A
310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310
D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A
310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310
D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A
310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310
D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A310D0A31
*/
- Dorian (MJT support)
- Automation Wizard
- Posts: 1380
- Joined: Sun Nov 03, 2002 3:19 am
- Contact:
Ollie,olllllliii wrote:Thank you Marcus ,
so i wrote a small script to get the lines of the data .
Here is the solution. It is much faster than the old version ..
// The old version is very slow on big files
Let>count=0
Let>filename=c:\daten4.txt
Label>Start
Let>count=count+1
ReadLn>filename,count,line
If>line=##EOF##,end
Goto>Start
Label>end
MessageModal>Number of lines in file = %count%
// end old version
// Very much faster to count lines
Kind regardsCode: Select all
Let>count=1 Let>filename=C:\Users\Steffen\Desktop\eue.csv CSVFileToArray>filename,arrCSV Label>Start Let>count=count+1 Let>data=arrCSV_%count%_1 Midstr>data,1,6,out If>out={"arrCSV"},end Goto>Start Label>end MessageModal>you have %count% lines in your file
Oliver
I used this multiple times today. Just wanted to say thank you. I think you may see it somewhere else soon... shh... secret.
Yes, we have a Custom Scripting Service. Message me or go here
-
- Pro Scripter
- Posts: 60
- Joined: Tue Dec 22, 2009 9:51 am
- Location: Mannheim ( Germany )
- Contact:
Re: How Arraycount after CSVFileToArray
The Final Linecount Programm ...much faster
Let>strDatei=C:\Users\Olllllliii\Desktop\yourfile.csv
ReadFile>strDatei,strData
Let>muster=CRLF
Regex>muster,strData,1,ArrZ,numArr,0,,
Let>info=numArr
MDL>info
This script is many times faster than the older ones
Let>strDatei=C:\Users\Olllllliii\Desktop\yourfile.csv
ReadFile>strDatei,strData
Let>muster=CRLF
Regex>muster,strData,1,ArrZ,numArr,0,,
Let>info=numArr
MDL>info
This script is many times faster than the older ones
Oliver Hilger Mannheim
alias Olllllliii
alias Olllllliii