LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

creating 1 million text files in labview

Dear Sir/Mam, i am trying to read data from serial port and saving it to a text file, i have to create around million of files in a month but my vi is only able to generate around 30,000 to 40000 files and after that the system goes slow, the main problen is that the vi takes a longertime to create a txt file, so when i have a large data sets the vi becomes slow  and when i change the folder location it start to work normal. can any one help me in this regard?

thanks

Download All
0 Kudos
Message 1 of 14
(2,995 Views)

You almost answered yourself. 1 million files per month means about one file every 2 seconds.

Such a huge number of files is unmanageable. You should try to cluster data together, for example generating one file per hour. Into the file, different acquisitions would be properly separated by a "marker" line, reporting e.g. the acquisition start time.

If you really want to save one file per acquisition, separate groups of file into different folders. 1 folder per day would mean about 40000 files in one directory, which in my opinion is still too much.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 14
(2,989 Views)

Or consider using a database. One million files a month would b every manageable. How will you analyze the data? How will user's try to work with that many files. Either try to store fewer files containing more data or use a database.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 3 of 14
(2,982 Views)

If you know that the Folder starts out empty and each file name is incremented by one, generate the file name yourself, keeping track of the current number.  You can use a file name format e.g. as "FILE%010d.dat" or "FILE%010x.dat" or similar. Even if the folder already has some files, it would be trivial to determine the highest suffix once before the program starts and then keep incrementing from there. Alternatively, you could e.g. format the current time stamp into a filename (guaranteed to be unique and sorted, if done correctly).

 

The tool "Create file name with incrementing suffix" Is the only thing that is holding you back, because with every call it does a "list folder" command, which gets more and more expensive as the number of files increases. Listing tens of thousands of file names to sort out what number comes next is not a trivial operation the way it is implemented. (You can open it to see what it does!).

 

Still, as the others above, I question the sanity of this approach overall. There are probably better ways to do all that than using the file system to segment data into tiny aliquots.

Message 4 of 14
(2,959 Views)

@lm35 wrote:

 the main problen is that the vi takes a longertime to create a txt file, so when i have a large data sets the vi becomes slow  and when i change the folder location it start to work normal. can any one help me in this regard?

thanks


Working with 1,000,000 files aside...

 

Is it the file creation or the data transmission that is taking too long? 

 

IF it is actually the file creation that is slowing everything down. I suggest using a Producer/Consumer architecture. The producer will collect the data and  pass it to the consumer,  that is now decoupled from the acquisition loop, so it can take its own sweet time creating files.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 5 of 14
(2,932 Views)

@RTSLVU wrote:

@lm35Is it the file creation or the data transmission that is taking too long? 

 


As I have explained, the only thing slowing things down is the use of "Create file name with incrementing suffix", which does a "list folder" with each call, parsing all existing file names to determine the next suffix. This is the only operation that increases in cost with the number of existing files. The cost of all other operations is constant.

Message 6 of 14
(2,928 Views)

@altenbach wrote:

The tool "Create file name with incrementing suffix" Is the only thing that is holding you back, because with every call it does a "list folder" command, which gets more and more expensive as the number of files increases. Listing tens of thousands of file names to sort out what number comes next is not a trivial operation the way it is implemented. (You can open it to see what it does!).


I haven't even looked at the code and this is instantly what I thought the problem would be.  But agree with everybody else, the shear number of files is insane.  I will side with Mark here: you really should be using a database.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 14
(2,921 Views)

Even the OS is probably not very happy with so many files in one folder. Just opening an explorer window, potentially sorting, showing the correct icon, etc. Is a big job. Same for the search indexer.

0 Kudos
Message 8 of 14
(2,910 Views)

@altenbach

i tried using filename but it generated around 90,000 files in 3 days and after that the system become too slow, windows os was creating trouble and there was a huge data loss because the file generation(create file with increment suffix) was taking a longer time, even i tried to split the files and folder that didn't work because it was even taking a longer time. the main problem is the create file command, as the no files increases the create file command takes longer time and so on...

0 Kudos
Message 9 of 14
(2,889 Views)

As explained others and by yourself, the speed issue is with the OS, not the program. Windows has speed problems with large amounts of files in one directory.

---------------------------------------------
Certified LabVIEW Developer (CLD)
There are two ways to tell somebody thanks: Kudos and Marked Solutions
0 Kudos
Message 10 of 14
(2,881 Views)