-1

I have a CSV file in swift and i am trying to parse it to make a database with tables and populate the data.Here is the format of my CSV.How to I separate the tables with there corresponding data.There are three tables all together.I tired a CSV parser from https://github.com/yaslab/CSV.swift but I cannot get the column data and its respective table

["table=account"]
["_id,company_id,name,device_id,location,length,alias,created_at,updated_at"]
["1,1,peter,1,0,51,5,Thu, 30 Jan 2020 09:48:06 -0700,Thu, 30 Jan 2020 09:48:06 -0700"]
["2,2,peter,1,51,51,5,Thu, 30 Jan 2020 09:48:47 -0700,Thu, 30 Jan 2020 09:48:47 -0700"]

["table=source"]
["_id,link,tab,company_id,created_at"]
["1,www.instagram.con,1,1,Thu, 30 Jan 2020 09:48:06 -0700"]
["2,www.puma.com,1,2,Thu, 30 Jan 2020 09:48:47 -0700"]


["table=company"]
["_id,name,website,created_at,updated_at"]
["1,instagram ,1,Thu, 30 Jan 2020 09:48:06 -0700,Thu, 30 Jan 2020 09:48:06 -0700"]
["2,puma,2,Thu, 30 Jan 2020 09:48:47 -0700,Thu, 30 Jan 2020 09:48:47 -0700"]
min
  • 1
  • 1
  • You need to focus your question because now it is very vague and it is hard to understand what your issue is. Understand that this is not a free code writing service where you supply some request and we write the code for you so post the code you are having an issue with and explain that issue. Also, if the above is your file then it is not CSV and you need to read and parse it manually. – Joakim Danielson Feb 06 '20 at 09:21
  • Thanks for the input @JoakimDanielson.I have found the errors in the CSV formatting and was able to solve this issue – min Feb 10 '20 at 19:42

1 Answers1

0

There was CSV formatting error and for multiple headers I appended the name of the table when writing the row data to the CSV and hence was able to separate the data with it'd respective row values

min
  • 1
  • 1