Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
housseinHTR
Contributor II
Contributor II

Read CSV file with space delimiter

Hello,

I have a csv file like this:

            11111111111            22222222222 33333333333333     xxxxxxxxxx

where the delimiter look like a single or multiple spaces.

In addition to that, the last column may contains spaces.

What is the best practice to read a similar file?

Thanks in advance.

Labels (3)
1 Solution

Accepted Solutions
akumar2301
Specialist II
Specialist II

I am assuming that only last column can have space. 

 

 

"^\\s*(\\w+)\\s+(\\w+)\\s+(\\w+)\\s+(.*)"

View solution in original post

6 Replies
akumar2301
Specialist II
Specialist II

Does your schema is static or Dynamic ? Do you know many fields(Without space) your input can have ?

housseinHTR
Contributor II
Contributor II
Author

Thanks Abhishek KUMAR for your reply.

The input file has always 4 columns, but the positions of the fields may change.i.e.:

11111111111 22222222222 333333333333 xxxxxxxxxxxxxx or

              11111111111 22222222222 333333333333 xxxx or 

  11111111111 22222222222 333333333333 xxxxxxxxxx or ....

Regards

akumar2301
Specialist II
Specialist II

try tFileInputregex

 

with regex expression 

"^\\s*(\\w+)\\s+(\\w+)\\s+(\\w+)\\s+(\\w+)\\s*"

housseinHTR
Contributor II
Contributor II
Author

Thank you again.

At first glance, it's works.

But when the last column contains space, it split the value and get only the first part.

Can you update the regex expression to resolve this issue?

Regards

akumar2301
Specialist II
Specialist II

I am assuming that only last column can have space. 

 

 

"^\\s*(\\w+)\\s+(\\w+)\\s+(\\w+)\\s+(.*)"

housseinHTR
Contributor II
Contributor II
Author

Thanks a lot, its works fine now.

Regards