yashsmehta / mysqldump-to-csv

Python script to convert .sql dump to CSV format
MIT License
78 stars 31 forks source link

Cannot process file due to csv header data #6

Open enaix opened 2 years ago

enaix commented 2 years ago

"SQL INSERT statement could not be found!" check is performed on all lines, in case if there is header data in the sql file, the script will refuse to process it. Skipping this line or disabling the exception until the first INSERT line is found are possible solutions.

deter3 commented 1 year ago

i use the code below to skip 42 lines .

` def main(): """ Parse arguments and start the program """

Iterate over all lines in all files

# listed in sys.argv[1:]
# or stdin if no args given.
try:
    counter = 0 
    for line in fileinput.input():
            counter += 1 
            if counter >= 43 :
                # Look for an INSERT statement and parse it.
                if not is_insert(line):
                    raise Exception("SQL INSERT statement could not be found!")
                values = get_values(line)
                if not values_sanity_check(values):
                    raise Exception("Getting substring of SQL INSERT statement after ' VALUES ' failed!")
                parse_values(values, sys.stdout)
except KeyboardInterrupt:
    sys.exit(0)

`

enaix commented 1 year ago

JIC here is the related PR #5

JohnPremKumar commented 1 year ago

Made a pull request to skip it in PR #8

enaix commented 1 year ago

It seems that the repo is dead.. Idk, it might be reasonable to create a fork or contact the owner

sblvkr commented 9 months ago

Thanks to the guys above, you saved my task