in Education by
I have csv file and that looks like following. I want to remove all rows before one row values [Station Mac, First time seen,Last time seen, Power, packets, BSSID,Probed ESSIDs] for further processing.I am using panadad libarary in python to read this csv file. I am able to remove particular rows by index, but my file reload after fes seconds nad row index can be changed. How should I do this. your help will be appreciated. BSSID, First time seen, Last time seen, channel, Speed, Privacy, Cipher, Authentication, Power, # beacons, # IV, LAN IP, ID-length, ESSID, Key 52:62:00:00:03:01, 2018-06-22 11:23:45, 2018-06-22 11:23:45, 9, -1, , , , -1, 0, 0, 0. 0. 0. 0, 0, , 14:30:04:B2:F5:42, 2018-06-22 11:24:04, 2018-06-22 11:24:04, 11, -1, WPA, , , -88, 0, 1, 0. 0. 0. 0, 0, , 14:30:04:D6C:95:62, 2018-06-22 11:23:50, 2018-06-22 11:24:08, 6, -1, WPA, , , -85, 0, 2, 0. 0. 0. 0, 0, , DC:09:4C:BF:6B:13, 2018-06-22 11:23:58, 2018-06-22 11:24:06, 7, 54, WPA2, CCMP, PSK, -75, 2, 0, 0. 0. 0. 0, 12, Death Stroke, B4:FB:N4:97:F8:03, 2018-06-22 11:23:46, 2018-06-22 11:24:12, 6, 54, WPA2, CCMP, PSK, -74, 6, 6, 0. 0. 0. 0, 3, CSE, C4:A8:1D:9K:B9:E8, 2018-06-22 11:23:57, 2018-06-22 11:24:12, 11, 22, WPA2 WPA, CCMP TKIP, PSK, -71, 1, 1, 0. 0. 0. 0, 20, SE-IX (Faculty Only), 78:8A:90:81:C1:31, 2018-06-22 11:23:54, 2018-06-22 11:24:06, 6, 54, WPA2, CCMP, PSK, -71, 4, 0, 0. 0. 0. 0, 3, CSE, 78:8A:20:49:^9:D1, 2018-06-22 11:23:44, 2018-06-22 11:24:12, 11, 54, WPA2, CCMP, PSK, -41, 58, 21, 0. 0. 0. 0, 3, CSE, 14:30:04:B3:FD:A2, 2018-06-22 11:23:46, 2018-06-22 11:24:12, 6, -1, , , , -1, 0, 0, 0. 0. 0. 0, 0, , 14:30:KL:B3:52:22, 2018-06-22 11:23:47, 2018-06-22 11:24:12, 2, -1, WPA, , , -1, 0, 50, 0. 0. 0. 0, 0, , 14:30:04:LC:9B:E2, 2018-06-22 11:23:48, 2018-06-22 11:24:01, 3, -1, , , , -1, 0, 0, 0. 0. 0. 0, 0, , 14:U0:04:B3:52:62, 2018-06-22 11:23:49, 2018-06-22 11:24:12, 11, -1, WPA, , , -1, 0, 92, 0. 0. 0. 0, 0, , Station MAC, First time seen, Last time seen, Power, # packets, BSSID, Probed ESSIDs macaddrees, 2018-06-22 11:23:45, 2018-06-22 11:23:45, -78, 8, 52:62:90:00:03:01, macaddress, 2018-06-22 11:23:46, 2018-06-22 11:24:05, -73, 4, 14:30:04:BB:19:A2, macaddress, 2018-06-22 11:23:52, 2018-06-22 11:24:12, -73, 5, (not associated) , macaddress, 2018-06-22 11:23:43, 2018-06-22 11:24:12, -71, 9, not assocaited, macadress, 2018-06-22 11:23:52, 2018-06-22 11:23:52, -70, 2, (not associated) , macaddress, 2018-06-22 11:23:48, 2018-06-22 11:24:01, -69, 11, NAN, macaddress, 2018-06-22 11:23:46, 2018-06-22 11:24:12, -65, 15, NAN, macaddress, 2018-06-22 11:24:12, 2018-06-22 11:24:12, -62, 2, (not associated) , macaddress, 2018-06-22 11:24:01, 2018-06-22 11:24:12, -54, 2, NAN, macaddress, 2018-06-22 11:23:49, 2018-06-22 11:24:12, -48, 97, NAN, macaddress, 2018-06-22 11:23:43, 2018-06-22 11:24:12, -35, 54, NAN,UET Smart University macaddress, 2018-06-22 11:23:47, 2018-06-22 11:24:03, -23, 108, NAN, macaddress, 2018-06-22 11:23:49, 2018-06-22 11:23:49, -1, 9, NAN, JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
We can read the file and then split it into the list s with 2 strings, one with everything before the empty line (using \n\n as the separator) and one with everything after. When this is done we can read these strings as CSV into separate DataFrames: with open('test.csv') as f: s = f.read().split('\n\n') df1 = pd.read_csv(pd.compat.StringIO(s[0])) df2 = pd.read_csv(pd.compat.StringIO(s[1])) df1: BSSID First time seen Last time seen channel \ 0 52:62:00:00:03:01 2018-06-22 11:23:45 2018-06-22 11:23:45 9 1 14:30:04:B2:F5:42 2018-06-22 11:24:04 2018-06-22 11:24:04 11 2 14:30:04:D6C:95:62 2018-06-22 11:23:50 2018-06-22 11:24:08 6 3 DC:09:4C:BF:6B:13 2018-06-22 11:23:58 2018-06-22 11:24:06 7 4 B4:FB:N4:97:F8:03 2018-06-22 11:23:46 2018-06-22 11:24:12 6 ... df2: Station MAC First time seen Last time seen Power # packets \ 0 macaddrees 2018-06-22 11:23:45 2018-06-22 11:23:45 -78 8 1 macaddress 2018-06-22 11:23:46 2018-06-22 11:24:05 -73 4 2 macaddress 2018-06-22 11:23:52 2018-06-22 11:24:12 -73 5 3 macaddress 2018-06-22 11:23:43 2018-06-22 11:24:12 -71 9 4 macadress 2018-06-22 11:23:52 2018-06-22 11:23:52 -70 2

Related questions

0 votes
    How can I remove emojis that start with '\x' when reading a csv file using pandas in Python? The ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    I want to select rows from a DataFrame based on values in some column in pandas, How can I do it? I ... WHERE column_name = some_value Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    Problem: Select first N rows and last row in Python Pandas. only gets 1 row which is index 9 and ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    Currently I'm returning column name of the max value in the each row. df['Active'] = df.idxmax( ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 5, 2022 in Education by JackTerrance
0 votes
    Currently I'm returning column name of the max value in the each row. df['Active'] = df.idxmax( ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    To the data frame df: Player Team Points Mean Price Value Gameweek 1 Jim Leeds 4.4 4.40 10.44 0.44 2 Jim ... scalar What am I missing? Select the correct answer from above options...
asked Jan 18, 2022 in Education by JackTerrance
0 votes
    I'm Running Ubuntu 16.04 LTS with Python 3.6.8 and I have the following code that allows me to ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 8, 2022 in Education by JackTerrance
0 votes
    A csv file consists of missing values that are represented by hashtags (“#”) and ampersands (“&”). How can you read this type of a csv file in R?...
asked Oct 16, 2020 in Technology by JackTerrance
0 votes
    I am trying to adjust the row height based on the cell value. The operation have to run through ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
0 votes
    I have an XML file which is structured as follows: place1 location1 place2 location2 place3 location3 These ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    for my university assignment, I have to produce a csv file with all the distances of the airports of ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 22, 2022 in Education by JackTerrance
0 votes
    for my university assignment, I have to produce a csv file with all the distances of the airports of ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Seven persons are to be seated in a row. Find the probability that 2 particular persons sit next to each other. Select the correct answer from above options...
asked Nov 25, 2021 in Education by JackTerrance
0 votes
    Seven persons are to be seated in a row. The probability that two particular persons sit next to each other is A. 1/3 B ... 2/7 D. 1/2 Select the correct answer from above options...
asked Nov 20, 2021 in Education by JackTerrance
0 votes
    If six students, including two particular students A and B, stand in a row, then the probability that A and B are ... 2/15 D. 4/15 Select the correct answer from above options...
asked Nov 16, 2021 in Education by JackTerrance
...