0

I have a csv list I would like to import to google. I downloaded the basic sample from google here it goes: cat contacts.csv

Name,Given Name,Additional Name,Family Name,Yomi Name,Given Name Yomi,Additional Name Yomi,Family Name Yomi,Name Prefix,Name Suffix,Initials,Nickname,Short Name,Maiden Name,Birthday,Gender,Location,Billing Information,Directory Server,Mileage,Occupation,Hobby,Sensitivity,Priority,Subject,Notes,Language,Photo,Group Membership,E-mail 1 - Type,E-mail 1 - Value,Phone 1 - Type,Phone 1 - Value,Phone 2 - Type,Phone 2 - Value
A Name,A,,Name,,,,,,,,,,,,,,,,,,,,,,,,,* myContacts,* ,[email protected],Mobile,+number,Versão antiga,+number

Then I have a list as:

name 1,email 1,49292304
name 2,email,3943984338
...

I crafted the following awk command:

awk -F "," {'sub("\r$", ""); print $1",,,,,,,,,,,,,,,,,,,,,,,,,,,,,," $2",",","$3","","'}  alunos.csv

It generated me a proper CSV which seems in accord with the sample google provided me but i have an error in import time. What am I missing?

3
  • 1
    Did you try adding the header line to the resulting CSV? Jan 31, 2021 at 20:05
  • That solved the issue!
    – vfbsilva
    Jan 31, 2021 at 20:27
  • @MartinHorský, Could you please write out the solution as well fro the sake of ana answer to question? Feb 1, 2021 at 13:08

1 Answer 1

1

Add the header line to the CSV.

awk -F "," 'BEGIN { print "Name,Given Name,Additional Name,Family Name,Yomi Name,Given Name Yomi,Additional Name Yomi,Family Name Yomi,Name Prefix,Name Suffix,Initials,Nickname,Short Name,Maiden Name,Birthday,Gender,Location,Billing Information,Directory Server,Mileage,Occupation,Hobby,Sensitivity,Priority,Subject,Notes,Language,Photo,Group Membership,E-mail 1 - Type,E-mail 1 - Value,Phone 1 - Type,Phone 1 - Value,Phone 2 - Type,Phone 2 - Value" } {'sub("\r$", ""); print $1",,,,,,,,,,,,,,,,,,,,,,,,,,,,,," $2",",","$3","","'}'  alunos.csv

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .