Solved

Import from comma delimeted text file

Posted on 2000-03-01
3
237 Views
Last Modified: 2013-12-18
Hi,

How can I easily import to a view a text file (MS Proxy Server Log File) that is comma delimeted?  It will be one document per line. And it must able to interpret Date/Time Field.


Reden
0
Comment
Question by:reden
  • 2
3 Comments
 
LVL 9

Expert Comment

by:Arunkumar
Comment Utility
Hi reden,

You got to have a form for this imported documents to be viewed.

Did you try importing txt files using the notes import feature File-Import

You can specify the form and also calculate the ields on document import.

You can improve your import by writing a format file with .col extn.

Also you can import using LotusScript
one line after another and creating a document for each read.

With which one you have a problem ?

-Arun
0
 
LVL 1

Author Comment

by:reden
Comment Utility
I already have a form, I tried File-Import Feature but it only have Tabular, Structured and Lotus 123 formats supported, If I try Tabular it goes in to a single field "Body"

How will I create a .col file?
0
 
LVL 9

Accepted Solution

by:
Arunkumar earned 50 total points
Comment Utility
Hi reden,

This is an example i have with me....

The text File has something like this...

======================================
aruna,27,09-15-72,3000
arunb,27,09-15-72,3022
arunc,27,09-15-72,3033
arund,27,09-15-72,3044
arune,27,09-15-72,3055
arunf,27,09-15-72,3066
arunh,27,09-15-72,30546
arunf,27,09-15-72,30345
arung,27,09-15-72,30432
aruns,27,09-15-72,30445
======================================

Write a view action that will contain the following code

====================================
Dim ss As New notessession
Dim ws as new notesuiworkspace
     Dim db As notesdatabase
     Set db = ss.CurrentDatabase    
     Dim doc As notesdocument
     Dim wholetxt As String
     Dim fileNum As Integer
     Dim counter As Integer
     Dim countRec As Integer
     
     fileNum% = Freefile()
     counter% = 0
'Specify the file    
     Open "c:\windows\desktop\import.txt" For Input As fileNum%
     Do While Not Eof(fileNum%)
   ' Read each line of the file.
          Line Input #fileNum%, wholetxt$
         
          pos = Instr(1,wholetxt,",")
          firsttxt = Left(wholetxt, pos -1)
          remtxt = Right(wholetxt , Len(wholetxt) - (Len(firsttxt) + 1))
         
          pos = Instr(1,remtxt,",")
          secondtxt = Left(remtxt , pos-1)
          remtxt = Right(remtxt , Len(remtxt) - (Len(secondtxt) + 1))
         
          pos = Instr(1,remtxt,",")
          thirdtxt = Left(remtxt , pos-1)          
          remtxt = Right(remtxt , Len(remtxt) - (Len(thirdtxt) + 1))
         
'          pos = pos = Instr(1,remtxt,",")
          fourthtxt = remtxt
'          remtxt = Right(remtxt , Len(remtxt) - (Len(fourthtxt) + 1))
         
         
          Set doc = db.CreateDocument
          doc.form = "import"
          doc.NameField = firsttxt
          doc.AgeField = secondtxt
          doc.dobField = Cdat(Format(thirdtxt,"MM/DD/YYYY"))
          doc.salField = fourthtxt
          Call doc.Save(True,False)          
          Delete doc
         
   ' Increment the line count.
          counter% = counter% + 1
     Loop

call ws.viewrefresh

====================================

Some tips:
1. Make sure you give the exact filepath for the location of the file
2. Make sure that you change the datatype of the fields that you want to create on the document (This decides the datatype of the fields)
3. The code works for only 4 fields and you may extend this to "n" just by cut and pasting the logic inside

Good Luck !

-Arun

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now