Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Integration > Import Txt documents

Forum

Search UsersRules
Import Txt documents
#1
Just came
Points:: 0
Joined:: Oct 31, 2011

I must import a large txt document with 256 columns and 200,000 rows. I use the TextReader method, but it last very  long. Can you help me with other idea of making the import so it work faster?

Profile
#2
Just came
Points:: 1
Joined:: Nov 1, 2011

If executioning context is Windows, then you can use MS FileSystemObject,

for example:
* bugt: removed by administrator. non-english sites links

Total line:

Code
    fso = NewCOMObject ("Scripting.FileSystemObject");
    file = fso.GetFile(stringFileName);
    
    TextStream = file.OpenAsTextStream(1, -1);
    //file = fso.OpenTextFile(stringFileName, 1, , 0);
 
    While file.AtEndOfStream=0 Do
        EachLineOfTextStream= TextStream.ReadAll();
        LetsHandlThisLine(EachLineOfTextStream);
    EndDo; 
 
    TextStream.Close();




Something like this

Profile
#3
Just came
Points:: 0
Joined:: Mar 12, 2012

I imported txt documents with 600,000 row and 55-60Mb size. I didn't have problem to read txt document. I used "TextDocument" method. I had another problem with the recording speed of the data into the database.
Do you write those data into the base ?

Profile
#4
Just came
Points:: 0
Joined:: Oct 29, 2011

In fact, the problem is saving/updating in the database, not reading the text file.
It is any posibility to bulk insert / update a catalog in the database with data from a text file?

Profile
#5
Just came
Points:: 1
Joined:: Nov 1, 2011

Actually it depends on many factors - first of all - what kind of data we want to ins ert in database. If it's InformationRegister - you can read whole text file, and insert it in database at once, in one RecordSet.
For AccumulationRegister may be more subtle to invoke Se tTotalsUsing(false) before writing data in database.

Profile
#6
Just came
Points:: 0
Joined:: Oct 29, 2011

The file is more a catalog than an InformationRegister. It is in csv format.
Because the file is very large and we get out of memory, we actually process it reading groups of lines, check if the records are already in catalog an update or insert if it is not there. But this takes very long time.
Any sugestion is verry wellcome.

Profile
#7
Just came
Points:: 1
Joined:: Nov 1, 2011

#6, what exactly takes long time - can you elaborate the whole process with more details?

Profile
#8
Just came
Points:: 7
Joined:: Mar 15, 2012

Did you try the TextReader object?

It was designed for sequential read text files with long length.

Code
Text = New TextReader("d:\win.txt");

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.