How to replace comma with newline n/ in a specific column content of a csv file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ulitech
    New Member
    • Sep 2015
    • 2

    How to replace comma with newline n/ in a specific column content of a csv file

    Example:
    having this header:
    User Name JobCodes

    and the data for each column:
    w004,William,10 0
    jme3,Jhon,200

    the challenge is coming here, this particular record has more than one "JobCode":
    v4002,Victor,30 0,400,500

    so, these 3 values belong only to "JobCode" column, How can i replace commas with newlines having the expected result for this particular record:

    v4002,Victor, 300
    400
    500

    it is possible to get this format for that particular column?? please help!!!
  • ulitech
    New Member
    • Sep 2015
    • 2

    #2
    the job codes should be listed in order, in this way inside JobCodes column:
    300
    400
    500

    Comment

    • RonB
      Recognized Expert Contributor
      • Jun 2009
      • 589

      #3
      Putting the JobCodes on separate lines like that will break the csv formatting. Instead, that list should be enclosed in quotes to retain proper csv format.

      Comment

      • Oralloy
        Recognized Expert Contributor
        • Jun 2010
        • 988

        #4
        ulitech,

        Are you looking to create a long-term tool, or a throw-away?

        In other words, what are the full requirements, so that we know best how to guide you.

        Take a look at the "awk" tool, as it should be able to solve your problem with a line or two.

        Alternately, the "sed" tool might be appropriate to your needs.

        Luck,
        Oralloy

        Comment

        Working...