0

I have a feed with the following columns:

product_name,description,aw_product_id,store_price,merchant_image_url,merchant_deep_link,merchant_category,merchant_product_id

Each line afterwards has all the information in this order. I only require the product_name for each line, not everything that comes afterwards.

So my question is, how do I remove everything and only keep the product_name?

logi-kal
  • 7,107
  • 6
  • 31
  • 43
shaunybhoy
  • 7
  • 1
  • 4

4 Answers4

4

You could use a regex to replace the comma and everything after it with nothing:

Search: ,.*

Replace: (nothing)

MRAB
  • 20,356
  • 6
  • 40
  • 33
0

As you want the first column, you can just use regex to extract the data, however things would be a lot more trickier if you wanted a column from the middle.

If that's the case, importing into a spreadsheet program such as Excel as a CSV file will extract all the data into columns which then allows you to highlight that column (or columns) and extract the data as necessary.

user3791372
  • 4,445
  • 6
  • 44
  • 78
0

You could use the Column mode (ALT + Mouseselect) to select only the part (column) you want. This could be tricky if the product name length is very unequal.

An other way would be Find+Replace with a clever RegEx. Thats what I would do in your case.

As the product name is the first column, deleting everthing behind the comma should do the trick. So use this regex and replace with an empty string:

Find: ,[\w]*
Replace: 
mcdikki
  • 109
  • 4
0

To remove the 6th column from a CSV file:

Find:(.*?)(,.*?)(,.*?)(,.*?)(,.*?)(?:,.*?)(,.*)

Replace:${1}${2}${3}${4}${5}${6}

Search Mode: Regular Expression

  • This removes the fifth column. Why all these capture groups, only 2 is enough. You should hanchor your regex. – Toto Jan 10 '23 at 13:19