Coverting a CSV with 2 tables to SQLite

Viewed 51

I have a CSV file that is produced via a program. (airodump-ng to be precise) that I would like to convert into a .db file a SQLite database.

I would preferably like it this was as to make the data a lot easier to navigate around but the issue I have is the the produced CSV has 2 separate tables within it.

Im not the most advantage user as this is kind of just a little fun project, so I found a python based script over at Github called csvs-to-sqlite.

I found various other but csvs-to-sqlite seemed to do exactly what I wanted to do.

BSSID, First time seen, Last time seen, channel, Speed, Privacy, 
Cipher, Authentication, Power, # beacons, # IV, LAN IP, ID-length, 
ESSID, Key
00:00:00:00:00:00, 2018-01-01 23:23:23, 2018-01-01 23:23:23,10,100, 
OPN,, PSK,-60,2,0,   0.  0.  0.  0,15,TestNode254846254, 
11:11:11:11:11:11, 2018-01-01 23:23:23, 2018-01-01 23:23:23,2,, 
WPA2, CCMP,   ,-67,1,0,   0.  0.  0.  0,13,WIFI456824625, 
22:22:22:22:22:22, 2018-01-01 23:23:23, 2018-01-01 23:23:23,4,, WPA2 
WPA, , MGT,-67,3,0,   0.  0.  0.  0,11,45895142357, 
,,,,,,,,,,,,,, 
Station MAC, First time seen, Last time seen, Power, # packets, 
BSSID, Probed ESSIDs,,,,,,,,
00:00:00:00:00:00, 2018-01-01 23:23:23, 2018-01-01 
23:23:23,-100,100, (not associated) ,Wifi,,,,,,,,
11:11:11:11:11:11, 2018-01-01 23:23:23, 2018-01-01 23:23:23,-55,3, 
(not associated) ,TestNode254846254,,,,,,,,
22:22:22:22:22:22, 2018-01-01 23:23:23, 2018-01-01 
23:23:23,-63,1,00:00:00:00:00:00,,,,,,,,,

As an inital test I ran the CSV through to see if a .db SQLite database would be produced and it worked as expected but of course due to the nature of the basic run the first table worked perfectly but the second table obviously appears mearly appears as data within the original table, I would like the data to be outputted into 2 separate tables if possible.

As it is a CSV the fields are of course separated via commas and the 2 tables are separates via 14 consecutive commas which appears when viewed as a spreadsheet and a blank line between the commas.

Does anyone potentially know how I could relativley easily convert my data over to SQLite.

Regards.

1 Answers

Is this a one-time task, and manual approach is ok? If so, you could use a text manipulation tool like Notepad++ that has regex search and replace, and regex search and replace the 14 commas and everything after them to the end of the line with an empty string.

Save to a separate file, and now you have a CSV file that only contains the first table.

Reload the original file, regex search and replace everything from the start of the line to end of the 14 commas, and now you have a csv file that only contains the second table.

Run each of the 2 tables through your csv to sql helper.

Related