| View previous topic :: View next topic |
| Author |
Message |
flippers Newbie

Joined: 17 Jan 2011 Posts: 2
|
Posted: Wed Aug 01, 2012 9:28 am Post subject: Importing from text file - multiple 'vertical' entries |
|
|
Ah, not sure how to ask this question, been searching for hours for a guide to filtering text files to create a suitable CSV format to then drop into Calc.
The problem is I have a text file that is generated by an HTML based email generator that produces a flat text file in this format:
(junk at beginning of email that needs to be purged)
-------------------------------------- (string of hypens)
Field1: data
Feild2: data2
Field3: data3
...
FieldX: dataX
-------------------------------------- (string of hyphens at the end of each email too)
Sometimes a field is missing if there was no data entered in the original html entry.
I want to find a script of some sort (a total newbie in scripts - and little time to learn) that will find the various fields and generate suitable CSV files that I can then dump into a spreadsheet.
What I did try was to merge all the groups of fields into a single text document thinking that would be easier to convert (not for me at least!).
Suggestions, links, etc. all appreciated.
Thanks in advance!
John :-#)# |
|
| Back to top |
|
 |
mgroenescheij Super User

Joined: 20 Apr 2011 Posts: 862 Location: Australia
|
Posted: Wed Aug 01, 2012 8:11 pm Post subject: |
|
|
Hi,
You could try this CSV editor:[url] http://csved.sjfrancke.nl/[/url] _________________ If your problem has been solved please add "[Solved]" to the beginning of your first post title (edit button). |
|
| Back to top |
|
 |
flippers Newbie

Joined: 17 Jan 2011 Posts: 2
|
Posted: Thu Aug 02, 2012 7:00 am Post subject: |
|
|
Unfortunately that program is not what I was looking for - or if it can, then it is not obvious from the help files. Played with it for an hour or so, but no further ahead with sorting issues.
Here is exactly what I am trying to do:
This script needed to do open text file (email text file) and do the following (for about 75 records) to generate a CSV file.
find "From: email@host.ext ()" email@host.ext is extracted and is the first item on a line
add comma
find "Date: day, xx mon year yy:zz:aa -tztz" (tztz = time zone) extract xx mon year - second item
add comma
find "Rider_Salutation: xxx" extract xxx, if blank put space(is space needed?)
add comma
find "Rider_Name: asdlfkjjk" extract asdlfkjjk
add comma
find "Rider_Address1: some address" extract some address, if blank put space(is space needed?)
add comma
find "Rider_Address2: some extra address" extract some extra address if blank put space(is space needed?)
add comma
find "Rider_Prov_State: XY" OR find "Rider_Prov_State: Prov/State: XY" extract XY, if blank put space(is space needed?)
add comma
and so on..
Looks like this:
email@host.ex,xx mon year,xxx, asdlfkjjk, some address, some extra address, XY, (etc.)
Then repeat with next record on a new line to end of file.
Raw file looks like this (redacted the email background info) bold is lines with data wanted, bold & underlined is actual data wanted is CSV layout
From - Thu Jun 28 14:26:32 2012
X-Account-Key: account3
X-UIDL: 00015d61490f4b81
X-Mozilla-Status: 0003
X-Mozilla-Status2: 00000000
X-Mozilla-Keys: paid
...stuff deleted
From: email@host.xx ()
...stuff deleted
Date: Thu, 28 Jun 2012 14:18:26 -0700
...stuff deleted
---------------------------------------------------------------------------
Rider_Salutation: Mr.
Rider_Name: HisName
Rider_Address1: HisAddress
Rider_City: City: HisCiity
Rider_Prov_State: Prov/State: bc
Rider_Country: Country: canada
Rider_Postal_Code: Postal Code: CodeHere
and so on...record after record
Thanks! |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|