web stats
Comma in a csv file - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 08-05-2013, 10:52 AM
rav rav is offline
Mirth Guru
 
Join Date: Oct 2012
Posts: 258
rav is on a distinguished road
Default Comma in a csv file

Hi,

We are receiving a CSV file with a comma in the coloumn.
java,abc h

I have to map the java to last name.
abc to first name and h to middle name.

The comma is moving this field to next tag. Any inputs please..It would be very helpful..
Reply With Quote
  #2  
Old 08-05-2013, 02:46 PM
rav rav is offline
Mirth Guru
 
Join Date: Oct 2012
Posts: 258
rav is on a distinguished road
Default

Any suggestions please...before applying .split() function I have to parse the comma..
Reply With Quote
  #3  
Old 08-06-2013, 07:03 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,116
narupley is on a distinguished road
Default

If that's meant to be a single column and the value isn't quoted, then it's invalid CSV. You'll need to go back to the source and tell them to stop sending you invalid data.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #4  
Old 08-12-2013, 05:49 AM
rav rav is offline
Mirth Guru
 
Join Date: Oct 2012
Posts: 258
rav is on a distinguished road
Default

Thanks Nick..Actually I was opening the csv file in excel which I see differently in a text editor file..Now I have the right csv one more question..

After each row I see additional ,,,,,,,,,,,,,,,,,,,,,,,, in the CSV file...How to parse that..Mirth is reading ,,,,,,,,,,,,,,,,,,,,,,,, this as a separate row..Any thoughts please..Below is the example

,,,,,,,,,,,,,,,,,,,,,,,,
###,"ABC,EFGH N",ABCD,N,EFGH,211 main st,XYZ,NMI,PA,18888,,,,,,,,,,,,,,,
Reply With Quote
  #5  
Old 08-12-2013, 07:26 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,116
narupley is on a distinguished road
Default

Quote:
Originally Posted by rav View Post
Thanks Nick..Actually I was opening the csv file in excel which I see differently in a text editor file..Now I have the right csv one more question..

After each row I see additional ,,,,,,,,,,,,,,,,,,,,,,,, in the CSV file...How to parse that..Mirth is reading ,,,,,,,,,,,,,,,,,,,,,,,, this as a separate row..Any thoughts please..Below is the example

,,,,,,,,,,,,,,,,,,,,,,,,
###,"ABC,EFGH N",ABCD,N,EFGH,211 main st,XYZ,NMI,PA,18888,,,,,,,,,,,,,,,
From the example you posted, Mirth is reading it as a separate row because it is a separate row.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #6  
Old 08-12-2013, 07:34 AM
rav rav is offline
Mirth Guru
 
Join Date: Oct 2012
Posts: 258
rav is on a distinguished road
Default

How to overcome this ? The rows are sperated with blank lines...Any inputs please...or any place where you can guide me where you already tackled the issue
Reply With Quote
  #7  
Old 08-12-2013, 07:36 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,116
narupley is on a distinguished road
Default

Quote:
Originally Posted by rav View Post
How to overcome this ? The rows are sperated with blank lines...Any inputs please...or any place where you can guide me where you already tackled the issue
I don't understand what you want to do... you just want to ignore the rows that have empty columns? Assuming you're iterating through the rows in a transformer, then you could just check whether the first column is empty (or you could check if all columns are empty) and just continue iteration.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #8  
Old 08-12-2013, 07:39 AM
rav rav is offline
Mirth Guru
 
Join Date: Oct 2012
Posts: 258
rav is on a distinguished road
Default

I have the following properties set up for my channel

1. Coloumn delimiter : ,
2. Record delimiter: /r/n
3. Coloumn names: static names
4. Split batch by record : checked
5. Number of header records: 1

Can changing the properties will ignore the blank row...Can you give me code snnipet..I am not using transformer at all I am mapping everything in code template..Converting CSV To JSON..Hopw this helps
Reply With Quote
  #9  
Old 08-12-2013, 07:42 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,116
narupley is on a distinguished road
Default

Quote:
Originally Posted by rav View Post
I have the following properties set up for my channel

1. Coloumn delimiter : ,
2. Record delimiter: /r/n
3. Coloumn names: static names
4. Split batch by record : checked
5. Number of header records: 1

Can changing the properties will ignore the blank row...Can you give me code snnipet..I am not using transformer at all I am mapping everything in code template..Converting CSV To JSON..Hopw this helps
Since you're splitting a CSV batch, there's no built-in functionality there to skip rows that have all blank columns. You could do that with a batch script instead, or just have a source filter that detects when all columns are blank and filter the message.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #10  
Old 08-12-2013, 07:44 AM
rav rav is offline
Mirth Guru
 
Join Date: Oct 2012
Posts: 258
rav is on a distinguished road
Default

Cool thanks a lot Nick...Will try this way...Appreciate your help
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 06:10 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation