0

I have to import a CSV file into MySQL table. The file and the table have the same structure (columns and types of values). The import should happen with following algo:

  • read a line from the file,
  • compare values from column X (file) with column X (db table),
  • import line, if the value in the file is higher, than the value in the db table.

The question is, slightly off-topic: how is it possible to automate this kind of import? Are there tools doing such? Or is PhpMyAdmin enough - create temporal table, put the file into it, compare and import?

Sterconium
  • 559
  • 4
  • 20
Evgeniy
  • 2,337
  • 2
  • 28
  • 68
  • Possible duplicate of [How to import CSV file to MySQL table](https://stackoverflow.com/questions/3635166/how-to-import-csv-file-to-mysql-table) – Sterconium Oct 28 '19 at 11:35
  • I think I would be tempted to import the whole thing first, and then run the comparison. – Strawberry Oct 28 '19 at 11:35
  • @Strawberry you could be right. I mean, it isn't a kind of unique task - i guess, there should be many solutions for it. But i'm struggle with finding a ready and automated one... – Evgeniy Oct 28 '19 at 11:38
  • @Sterconium: no, it isn't a duplikate. It is fully other kind of import i want to do, as it is in the topic you cited. – Evgeniy Oct 28 '19 at 11:50

1 Answers1

0

For everybody, who is looking for same or similar solutions:

  • The tool, which helps to accomplish such tasks, is calles webyog (no link - its not an advertising, search for it),
  • The tool has possibility to specify SQL query, which will rule the import.

An answer about this solutions is provided by the tool's support - should work as expected. For me, it will be the accepted solution.

Evgeniy
  • 2,337
  • 2
  • 28
  • 68