![]() |
CSV process - using repeating items |
Post Reply
|
Page 12> |
| Author | |||
Daniel
Admin Group
Technical Director Joined: 19 Dec 2006 Location: Stoke-on-Trent Posts: 875 |
Post Options
Quote Reply
Topic: CSV process - using repeating itemsPosted: 23 Jul 2008 at 11:04am |
||
|
This is a sample for extracting an e-mailed piece of CSV and putting it into a database.
Here is the sample csv I am working from:
1. Create your account, (don't set up your message retrieval yet). ![]() 2. Create your new trigger, for parsing the csv data into lines. ![]() 3. Add a field - paste your data into the right hand window. ![]() 4. Enable "is repeating block" and set the look for to \r\n[^\r\n]+ (a line feed followed by as many characters as possible that aren't line feeds). ![]() 5. On the "extract data" tab, enable "use the find mask". ![]() 6. Enable the extract script, and select edit. The paste in the following code to the window. This code removes " and uses a replacement method to escape commas (which we will undo in the next trigger). This also replaces empty fields with a better value for extraction at the next stage.
![]() 7. Go back to the "general" tab, and check then uncheck "is repeating block" to get Email2DB to reprocess the regular expression. 8. OK the field and OK the trigger. 9. Add a new trigger for the line. ![]() 10. Add a new field to the trigger, and paste one of the lines from the csv to the right hand window. ![]() 11. Enter the name of the field, then in look for enter *, and on "extract data" "until these characters" enter , ![]() 12. Repeat for each field, except for these fields, it should be look for , extract until , and for the last field it should be extract until end of line. ![]() 13. In fields where commas could be part of the data (usually free text style fields) go to the extract data tab of the field, and enter the code:
This undoes what we did in step 6. ![]() 14. Ok this trigger, and open the multiple lines trigger. Go into the line extraction field, then to the "pass to" tab. Select the Line trigger from the drop down. Other settings should be fine on defaults. ![]() 15. Run a test, and make sure your fields are extracted correctly. 16. Set up the line trigger to update your database or whatever actions you want to do with the data. Here is the accounts to import into Email2DB 2: uploads/1089/CSVParse.vdb Edited by Daniel - 23 Jul 2008 at 11:46am |
|||
|
Daniel Tallentire
Support Parker Software |
|||
![]() |
|||
vinchu
New User
Joined: 16 Mar 2006 Posts: 5 |
Post Options
Quote Reply
Posted: 30 Sep 2008 at 5:31pm |
||
|
Hi Daniel, Thanks for that post, I think that give me some hope to solve my issue.
The issue I am having is when an email address contains ' (quotes), when it passes to SQL server by email2db, it just trucate the rest of the sql statment.
How to work with the system built-in field %msg_from%?
Any code example will be appeciated.
Thanks,
|
|||
![]() |
|||
vinchu
New User
Joined: 16 Mar 2006 Posts: 5 |
Post Options
Quote Reply
Posted: 30 Sep 2008 at 5:52pm |
||
|
that's my plug - not sure how it can with the system built-in field %msg_from% ??
Sub Main() ' commands start here
Dim vbDash As String
Dim Email2DBExtract2 As String vbDash = Chr(39)
Email2DBExtract2 = "abc'abc"
If InStr(Email2DBExtract2, vbDash) >0 Then Email2DBExtract2 = Replace(Email2DBExtract2, "'", "''")
Debug.Print Email2DBExtract2 End If
End Sub |
|||
![]() |
|||
Daniel
Admin Group
Technical Director Joined: 19 Dec 2006 Location: Stoke-on-Trent Posts: 875 |
Post Options
Quote Reply
Posted: 20 Oct 2008 at 11:02am |
||
|
Hi,
To do it with a system field use the field MSG_FROM in the script. This can be edited in the same was as any script value. |
|||
|
Daniel Tallentire
Support Parker Software |
|||
![]() |
|||
mitesh281
New User
Joined: 24 Feb 2009 Posts: 32 |
Post Options
Quote Reply
Posted: 03 Mar 2009 at 1:14pm |
||
|
Hi Daniel,
I am trying to use repeating block feature for below formate of email.
Client Name : Test
Client Type : Test1 Layer Name : Test Service : NONE Test : Yes Description : Test1 Last Measure : 1.0 Mins Service : NONE Test : No Description : Test2 Last Measure : 4.0 Mins Priority : Critical Start Time : Feb 01, 2009 01:31:56 Can you please guide me on this?
Thanks.
|
|||
![]() |
|||
Daniel
Admin Group
Technical Director Joined: 19 Dec 2006 Location: Stoke-on-Trent Posts: 875 |
Post Options
Quote Reply
Posted: 06 Mar 2009 at 12:46pm |
||
|
Hi Mitesh,
You should use a regular expression to grab the block (this sort of block are the least easy to do). Look for should be Service : [A-Za-z]*[\r\n]+[A-Za-z0-9 ]*[\r\n]+[A-Za-z0-9 ]*[\r\n]+[A-Za-z0-9. ]* Then the 2nd tab should have "use the find mask" checked. |
|||
|
Daniel Tallentire
Support Parker Software |
|||
![]() |
|||
Webtrix
New User
Joined: 10 Aug 2010 Posts: 3 |
Post Options
Quote Reply
Posted: 11 Aug 2010 at 12:43am |
||
|
I am having some trouble doing this. I followed this step by step, but it does not work for me. When i use the "Run Test" feature everything works smoothly however when i email it from an outside source, the data from my csv file is not getting passed from the email to the triggers. any help would be greatly appreciated.
|
|||
![]() |
|||
James Horton
Admin Group
Technical Support Joined: 01 Jun 2009 Location: Stoke-on-Trent Posts: 277 |
Post Options
Quote Reply
Posted: 12 Aug 2010 at 10:54am |
||
|
Hi Brian,
Thanks for contacting support@parker-software.com. We shall resume communication via email for the time being and if I find your problem I will update both this and contact you via email.
|
|||
|
Best Regards,
James Horton Technical Analyst Parker Software |
|||
![]() |
|||
James Horton
Admin Group
Technical Support Joined: 01 Jun 2009 Location: Stoke-on-Trent Posts: 277 |
Post Options
Quote Reply
Posted: 23 Jun 2011 at 5:36pm |
||
|
If you are expecting multiple blank items within a row of data then please use the following script in your CSVLine trigger:
|
|||
|
Best Regards,
James Horton Technical Analyst Parker Software |
|||
![]() |
|||
Daniel
Admin Group
Technical Director Joined: 19 Dec 2006 Location: Stoke-on-Trent Posts: 875 |
Post Options
Quote Reply
Posted: 17 Aug 2011 at 10:47am |
||
|
If you want to extract a maximum of X lines from the script, first setup an empty field extraction above the CSV Line extraction, and name it LineCount.
Now, modify the CSV extraction to:
This will cancel the trigger once the execution reaches the linecount, so no more messages would be passed through.
Edited by Daniel - 17 Aug 2011 at 5:19pm |
|||
|
Daniel Tallentire
Support Parker Software |
|||
![]() |
|||
Post Reply
|
Page 12> |
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |