1

I have data stored in text file ( UTF-8 ) , each line has data for a separate column in database.

I have stored data in a sequence. I need to read the file and store each line as an Array then use these Array in a SQL query to put data in MySql database file.

I have tried to figure out from all relevant questions on the subject in various questions.

Thank you

qasim
  • 29
  • 3
  • This is too broad of a topic for SO. Have you established a DB connection? Where are you having issues? To import a file line by line you could use `fread` with `fopen`. You also might be able to use `file` depending on how big the file is how much memory you have and what your configuration allows. If your issue is specific to character encoding please add code and explain that part. – user3783243 Apr 19 '20 at 14:23
  • probably encoding issue . Have Connection, SQL queries working , need to read file , store each line as array element , have a symbol as separate line to mark end of Row, so that next record will start. Have 1000 records , few lines have data approx 400 characters including spaces. – qasim Apr 19 '20 at 14:51
  • You need to be more specific. Where is your issue, reading file, splitting, inserting, after insertion with stored data, etc.? – user3783243 Apr 19 '20 at 15:00
  • `LOAD DATA` can handle multi-line rows. Let's see an example of two "rows" of data and the desired `CREATE TABLE`. – Rick James Apr 20 '20 at 18:39

0 Answers0