How to get row count of csv using ObjectScript
Hi,
I have written a procedure with the help of object scripting to export data to a csv file. There is more data than the csv limit.
Can anyone please tell me how to get the row count of csv file using object scripting, so that I can write an if condition and write to a second csv file.
Please find the code writing to the csv given below.
while (ind '= ""){
set row = ^CacheTemp(repid,"MAIN",ind)
use filemain write row,!
; Get next row index for MAIN report
set ind = $order(^CacheTemp(repid,"MAIN",ind))
} close filemain
}
Thanks
Jude
Here are a couple of ways for getting information about a file:
Get file size:
Get number of lines:
Hi Eduard,
I am writing a routine to extract data from database and scheduled for a particular day. Recently I came across that the data is going beyond the csv limit.
Thanks
Jude
Could you please send me a sample code.
Many thanks
Can you show your code and explain what are you trying to achieve?
Hi,
I need to write to different csv files based on a column data. So I need to check the column data before writing to file.
Here is the code to write the data to file.
while (ind '= ""){
set row = ^CacheTemp(repid,"MAIN",ind)
use filemain write row,!
; Get next row index for MAIN report
set ind = $order(^CacheTemp(repid,"MAIN",ind))
} close filemain
}
Thanks
Jude
Something like this?
I am looking something similar like that but based on a particular table column data.
thanks
Show examples of the row variable. What condition do you want to check?
Sure, why not?
For example:
Are you by chance exporting SQL queries to CSV? If so it can be done automatically:
Is there any way we can check a particular column data before writing to the file ? Based on the data I can write the data to a different files.
I don't think it's a CSV limit.
Device's limit : yes; CSV's limit : no.
This will do exactly what you want any problems give us shout
A very simple approach just in case... but if ind is numeric you can try to get the first and last ones with:
set first = $order(^CacheTemp(repid,"MAIN","" ))
set last = $order(^CacheTemp(repid,"MAIN","", - 1))
and then do the math to know how many entries (at most) there can be.
Social networks
InterSystems resources
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue