Skip to main content
Question

Replace commas within quotes when using CSV Reader

  • November 9, 2017
  • 8 replies
  • 58 views

sunsilk11
Contributor
Forum|alt.badge.img+6

Hi I have a CSV file with X,Y coordinates. I am loading this to a point feature class. However the XY coordinates sometimes come in quotes and have a comma, e.g.

GLOUCESTERSHIRE,ST BRAIVELS COMMON,GL15 6SD,"355,280","203,644"

Any suggestions what's the best way to handle this when using the CSV reader.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

8 replies

david_r
Celebrity
  • November 9, 2017

How is "355,280" to be interpreted?

As x=355.28 or as (x=355, y=280)?


dustin
Influencer
Forum|alt.badge.img+31
  • Influencer
  • November 9, 2017

Look into using the StringReplacer to remove unwanted characters.


sunsilk11
Contributor
Forum|alt.badge.img+6
  • Author
  • Contributor
  • November 9, 2017

I need to interpret this as 355280

StringReplacer doesn't seem to work for me


david_r
Celebrity
  • November 9, 2017

Use a StringReplacer to replace the comma "," with an empty string.

Result:

csv2none.fmwt


dustin
Influencer
Forum|alt.badge.img+31
  • Influencer
  • November 9, 2017

I need to interpret this as 355280

StringReplacer doesn't seem to work for me

@sunsilk11 - Could you attach your CSV file?

 


dustin
Influencer
Forum|alt.badge.img+31
  • Influencer
  • November 9, 2017

Use a StringReplacer to replace the comma "," with an empty string.

Result:

csv2none.fmwt

Similarly, you can use regular expression to remove both the quotes and comma at the same time, if that's what you are needing.

 


david_r
Celebrity
  • November 9, 2017
Similarly, you can use regular expression to remove both the quotes and comma at the same time, if that's what you are needing.

 

The CSV reader removes the double quotes by default, so it shouldn't be necessary. See the template workspace I uploaded.

 

 


Forum|alt.badge.img+1

If you are more comfortable with Excel, then you could also open the CSV file in Excel and change the data type of the X and Y coordinate fields to be number without a comma separator, then save it as CSV again,.. and read it into FME using the CSV reader without having to worry about it.