Question: I want to change CSV file content:

```
itemId,url,name,type
1|urlA|nameA|typeA
2|urlB|nameB|typeB
3|urlC,urlD|nameC|typeC
4|urlE|nameE|typeE

```

into an array:

```
[itemId,url,name,type]
[1,urlA,nameA,typeA]
[2,urlB,nameB,typeB]
[**3**,**urlC**,nameC,typeC]
[**3**,**urlD**,nameC,typeC]
[4,urlE,nameE,typeE]

```

Could anybody teach me how to do it?
Finally, I'm going to DL url files(.jpg)

Answer: 
The header row has a different separator than the data. That's a problem. You need to change the header row to use `|` instead of `,`. Then:

```
require 'csv'
require 'pp'

array = Array.new
CSV.foreach("test.csv", col_sep: '|', headers: true) do |row|
  if row['url'][/,/]
    row['url'].split(',').each do |url|
      row['url'] = url
      array.push row.to_h.values
    end
  else
    array.push row.to_h.values
  end
end

pp array

=> [["1", "urlA", "nameA", "typeA"],
    ["2", "urlB", "nameB", "typeB"],
    ["3", "urlC", "nameC", "typeC"],
    ["3", "urlD", "nameC", "typeC"],
    ["4", "urlE", "nameE", "typeE"]]

```
You'll need to test the fifth column to see how the line should be parsed. If you see a fifth element (row[4]) output the line twice replacing the url column

```
array = Array.new
CSV.foreach("test.csv") do |row|
  if row[4]
    array << [row[0..1], row[3..4]].flatten
    array << [[row[0]], row[2..4]].flatten
  else
    array << row
  end
end
p array

```

In your example you had asterisks but I'm assuming that was just to emphasise the lines for which you want special handling. If you do want asterisks, you can modify the two array shovel commands appropriately.