Convert .sql to .csv
by Crazy driver - April 27, 2021 at 05:01 AM
#13
(April 28, 2021 at 10:30 PM)bluedawning Wrote: Why not use Python to parse it?


MemoryError.........

NVR mind guys, I found a way to do it with sqlite.

THREAD CLOSED........
Reply
#14
(April 28, 2021 at 08:03 PM)verking Wrote:
(April 27, 2021 at 09:37 AM)LulzSecurity Wrote: https://anonfiles.com/j1L9tctau3/sql2csv_py

import re
import sys


def get_file_paths():
    #remove THIS filename from sys.argv if it's in there
    args = sys.argv
    if __file__.rstrip('.py') in args[0]:
        del args[0]
    try:
        input_file_path = args[0]
    except IndexError:
        print "Usage: sql2csv input_file [output_file]"
        sys.exit(1)
    try:
        output_file_path = args[1]
    except IndexError:
        output_file_path = "%s-sql2csv.csv" % input_file_path
    return input_file_path, output_file_path


def is_separator(line):
    """ Is the line just +-----+----+ ?"""
    return re.match("\+[+-]+\+", line)


def convert_line(line):
    #TODO: this could be better, as at the moment it removes all whitespace
    line = line.strip("|")
    line = line.replace("|", ",")
    line = line.replace(" ", "")
    return line


def convert_file(sql_file, csv_file):
    for line in sql_file.readlines():
        if is_separator(line):
            continue
        line = convert_line(line)
        csv_file.write(line)


def main():
    input_file_path, output_file_path = get_file_paths()
    sql_file = open(input_file_path, "r")
    csv_file = open(output_file_path, "w")
    convert_file(sql_file, csv_file)
    sql_file.close()
    csv_file.close()
    print "Done"
    sys.exit(0)

if __name__ == "__main__":
    main()


You're welcome Smile

Lol why re-upload to anonfiles, it's on Github:

https://github.com/adamalton/sql2csv/blo...sql2csv.py

--

Download MySQL to your machine, then write a script to pull results from the database and output to CSV. Similar to here:
https://github.com/saianupkumarp/sql2csv

Trying to simply convert from a file only will be a fucking tough challenge whereas the above will likely be simple if you can use google.


I said that it's on github, I said also I couldn't find the original GIT

thanks for the link though! There are a few sql2csv on github so I couldn't remember which it was and didn't bother checking the code

Cheers bro

Also show up in shoutbox more bby Heart @ verking
Reply
#15
(April 29, 2021 at 04:09 AM)LulzSecurity Wrote:
(April 28, 2021 at 08:03 PM)verking Wrote:
(April 27, 2021 at 09:37 AM)LulzSecurity Wrote: https://anonfiles.com/j1L9tctau3/sql2csv_py

import re
import sys


def get_file_paths():
    #remove THIS filename from sys.argv if it's in there
    args = sys.argv
    if __file__.rstrip('.py') in args[0]:
        del args[0]
    try:
        input_file_path = args[0]
    except IndexError:
        print "Usage: sql2csv input_file [output_file]"
        sys.exit(1)
    try:
        output_file_path = args[1]
    except IndexError:
        output_file_path = "%s-sql2csv.csv" % input_file_path
    return input_file_path, output_file_path


def is_separator(line):
    """ Is the line just +-----+----+ ?"""
    return re.match("\+[+-]+\+", line)


def convert_line(line):
    #TODO: this could be better, as at the moment it removes all whitespace
    line = line.strip("|")
    line = line.replace("|", ",")
    line = line.replace(" ", "")
    return line


def convert_file(sql_file, csv_file):
    for line in sql_file.readlines():
        if is_separator(line):
            continue
        line = convert_line(line)
        csv_file.write(line)


def main():
    input_file_path, output_file_path = get_file_paths()
    sql_file = open(input_file_path, "r")
    csv_file = open(output_file_path, "w")
    convert_file(sql_file, csv_file)
    sql_file.close()
    csv_file.close()
    print "Done"
    sys.exit(0)

if __name__ == "__main__":
    main()


You're welcome Smile

Lol why re-upload to anonfiles, it's on Github:

https://github.com/adamalton/sql2csv/blo...sql2csv.py

--

Download MySQL to your machine, then write a script to pull results from the database and output to CSV. Similar to here:
https://github.com/saianupkumarp/sql2csv

Trying to simply convert from a file only will be a fucking tough challenge whereas the above will likely be simple if you can use google.


I said that it's on github, I said also I couldn't find the original GIT

thanks for the link though! There are a few sql2csv on github so I couldn't remember which it was and didn't bother checking the code

Cheers bro

Also show up in shoutbox more bby Heart @ verking

Lol it's all good baby Heart good share either way man
Reply
#16
if you want to convert .sql to .csv perfectly,you must study the .sql file format,adjust the script.
This forum account is currently banned. Ban Length: 1 Week (4d, 19h, 2m remaining).
Ban Reason: Releaking content.
Reply
#17
Only convert it if your pc can handle converting big files
Reply

Possibly Related Threads…
Thread Author Replies Views Last Post
How TO Convert OST files into PST files & Office 365 edwinjarvis321 1 883 June 22, 2019 at 11:18 AM
Last Post: aaronfortin
SQL Scanner A tool that uses public proxies to find and scan sites for sql injection teamkelvinsecteam 0 813 January 04, 2019 at 10:39 PM
Last Post: teamkelvinsecteam
convertion mysql dump into csv itsmynew 11 2,725 August 04, 2017 at 03:34 PM
Last Post: samofstan

 Users browsing this thread: 1 Guest(s)