All Questions
278 questions
0
votes
0
answers
29
views
Python Dataframe columns problem (disapear)
From a previous question I asked, I wanted to create and sort a certain Parent/Child hierarchy recursively.
With the huge help of one member, he find me a solution to complete this work.
But, yeah ...
0
votes
0
answers
30
views
How to groupby(col1) and sum(col2), (col3), (col 4)
I want to make a function that creates a data table of the sum of each indicator for each site.
I need to group by the site, as there are 100 Devons, 70 Cornwalls and so on, so that Site is the ...
0
votes
3
answers
128
views
Pandas column has multiple values through multiple rows
I have this sample dataset from a csv file.
Year
Genre
1894
Romance
1906
Biography, Crime, Drama
1911
Drama
1912
Drama, History
1911
Adventure, Drama, Fantasy
1912
Biography, Drama
1919
...
0
votes
1
answer
60
views
Sorting a CSV file using key words inside of a column
I am trying to use Python to group transactions on a bank statement. The transactions are listed in a CSV file. I can't get it to use a portion of the description instead of the entire description.
I ...
0
votes
3
answers
557
views
Sorting CSV with IP address column in pandas
I have a CSV file with a column of IP addresses, MAC addresses and some other data. I want to sort all of the data by the IP addresses in ascending order
Input:
| IP Address | MAC Address | ID |
...
0
votes
1
answer
76
views
How can I sort the data from csv file in python in ascending order by name?
import csv
sure="y"
def create():
s="y"
f=open("tele.csv","w",newline="")
print("="*184)
print(" "*77,"...
0
votes
1
answer
78
views
I am trying to sort a csv alphabetically but its not happening
I am trying to sort a csv file alphabetically by the package column. I am using this code
import pandas as pandasForSortingCSV
# assign dataset
csvData = pandasForSortingCSV.read_csv("...
0
votes
1
answer
148
views
Need to order column data in CSV files to match the Row 1 header, but only move the row 2 and below data
I am stuck on an issue in which I have a CSV file and need to keep all the headers in row 1 in the specific order I was given, but the row 2 and below data for some of the columns are displaced ...
0
votes
1
answer
41
views
How to sort a nested list through one of its elements?
I have a program to make a bookstore database, and I have used CSV to store my data, through using nested list with each list as an entry for a particular book. The fields are ["Book ID",&...
0
votes
1
answer
36
views
Having trouble resorting a CSV file according to a different columns contents
Hey everyone I have been trying to sort a CSV file I requested from coin Market Caps API. After I got the data into a CSV file I then tried to make a new data frame called new_list that would sort the ...
0
votes
3
answers
76
views
Comparing 2 CSV files with Domain and IP. Rows are in different order. Reading Row 1 File X compare with all Rows in File Y
so i've looked online at a far exmaples but they all seem to assume the data is in order.
So Row 1 in Both files has the same information.
In my case Row 1 File X has an IP and DNS. The idea is to ...
0
votes
1
answer
558
views
Python: How to correctly convert CSV without headers to JSON
I have to convert a lot of CSV files to JSON files. As you can see below there are no headers.
I have managed to create code for that:
import gspread
import os
from googleapiclient.discovery import ...
0
votes
1
answer
49
views
sorting the column of csv file through an element (scores) without using pandas
I'm having trouble sorting the scores on my data without using pandas. Here's my code below:
def loadData():
fileHandle = open('Leaderboard.csv', 'r')
player = {}
for line in fileHandle:
...
0
votes
0
answers
33
views
Variables are not incrementing and unable to sort list
I have been attempting to make a practice program to score points for correct answers in a quiz.
The score isn't changing or rather holding the values, but resetting to zero.
Additionally, The score ...
0
votes
1
answer
2k
views
Parse CSV data to get a count on rows with duplicate values
I have a csv file (data.csv):
data
cn=Clark Kent,ou=users,ou=news,ou=employee,dc=company,dc=com
cn=Peter Parker,ou=News,ou=news,ou=employee,dc=company,dc=com
cn=Mary Jane,ou=News_HQ,ou=news,ou=...
1
vote
1
answer
502
views
Compare data between two csv files and count how many rows have the same data
Let's say I have list of all OUs (AllOU.csv):
NEWS
STORE
SPRINKLES
ICECREAM
I want to look through a csv file (samplefile.csv) on the third column called 'column3', and search through each row if it ...
0
votes
2
answers
2k
views
I want to compare 2 csv files that is file 1 and file 2 on basis of column
I want to compare 2 csv files that is file 1 and file 2 on basis of column. If column of file 1 matches with column of file 2 then remove that entire row of file 1.
Example of file 1
sr. no.,username,...
0
votes
0
answers
193
views
How to print the sum of a column from a CSV file without using pandas?
I do have a CSV file for example called PC_Sales.csv with sorted values according to Country and Year.
Country Year Manufacturer Sales_Unit
India 2017 ...
0
votes
0
answers
522
views
Compare Two large csv files
I am trying to compare two large CSV files( 260Gb and 16gb) , I have two approaches in mind,
taking out particular columns(using column numbers), append to new csv. I think it might reduce size and ...
0
votes
1
answer
20
views
Compare 2 CSV files based on a column and then merge them
I have 2 CSV files and I would like to merge them together.
The second CSV should be integrated into the first, so to speak, so both IP columns should be compared and the ports should then be copied ...
0
votes
2
answers
119
views
Two CSV files with data in different orders (No Pandas)
I have two csv files simulating patient data that I need to read in and compare.
Without using Pandas, I need to sort the second file by Subject_ID and append the sex of the patient to the first csv ...
0
votes
2
answers
895
views
CSV Python: How to combine duplicates in column A and put A-attached values together in Column B?
In a CSV file, I have duplicate values in column A, but they have different values in column B. I would like the value (IP) in column A to be reduced to one line and the individual associated ...
1
vote
1
answer
108
views
Sort elements in a list based on a csv column (Python)
I have a list that contains different paths to files. I want to sort the elements in this list by matching the stem of these paths (i.e. the file name) with a column in a csv file that contains the ...
1
vote
4
answers
3k
views
How do I sort a csv file so that my columns are in descending order?
I'm trying to sort my CSV file so that the teams with the most gold, silver and bronze medals are at the top of the list and those with the least are at the bottom.
def rank_team(file_name):
import ...
0
votes
2
answers
486
views
How can I sort and concat a csv file in a dataframe
I'm currently in a project and I need to work with a lot of CSV files, which are filled with data something like this:
CSV1.csv
A B C D ...
1 1980 1 0.9 0.8
2 ...
1
vote
2
answers
1k
views
Sort a CSV in Python by a column with a numerical value (and a header)
I have a csv file called "CleanReport.csv" with some sample data, shown here:
Name,Color,Age
Mark,Red,9999
Bob,Red,712
Alice,Green,1
Lisa,Pink,99
Jacob,Yellow,33
Corey,Orange,44
And using ...
0
votes
2
answers
195
views
Python Sorting Data From CSV File [duplicate]
so i'm trying to sort by value bunch of data from csv file , but the output is wrong . so any opinion ?
Note : i should solve it without pandas.thanks
import csv
import operator
with open('final.csv',...
1
vote
2
answers
609
views
Sort result from dictionary read from CSV file
I have a CSV file with many columns and rows, and I wanted to create a dictionary from one specific row (row 12 as shown in code), that have duplicates. I have managed to do this, however, I cannot ...
0
votes
2
answers
82
views
order raws based on name and number of header python
I have a csv file with raws of different sizes that contain values and a header for each raw.
00_A1_s1
00_A1_s2
00_A1_s3
04_A1_s1
04_A1_s2
04_A1_s3
08_A1_s1
08_A1_s2
08_A1_s3
and I want to group the ...
0
votes
2
answers
108
views
What's wrong with this code for sorting csv file according to date?
I have this csv file which look like this:
datetime_period,value
01 Apr 2021 00:00,92.85
01 Apr 2021 00:30,91.73
11 Feb 2021 19:30,88.58
11 Feb 2021 20:00,88.58
13 Jan 2021 13:00,80.49
13 Jan 2021 13:...
0
votes
2
answers
71
views
Why won't my dictionary sorting function work properly?
I have an assignment to import a data set from a csv, and the final portion of the assignment has me stuck, specifically:
The countries are listed in order from most populous (China) to least (Holy ...
0
votes
1
answer
844
views
How to sort ip addresses in csv file using python3
I have a csv file that looks like this:
IP Address,Port,Protocol,State
192.168.3.1,53,tcp,open
192.168.13.100,80,tcp,open
192.168.3.1,443,tcp,close
192.168.3.71,1080,tcp,open
192.168.3.7,8888,tcp,open
...
0
votes
1
answer
456
views
Reading, formatting, sorting, and saving a csv file without pandas
I am given some sample data in a file --> transactions1.csv
transactions1
I need to do code a function that will do the following without using pandas:
Open the file
Sort the index column in ...
0
votes
0
answers
166
views
sorting data (latest on top) with particular date in CSV file
I have a excel file which i read and convert into csv file after get two column out of all column in file . I want a csv file which have two columns which is Oder date(Latest on top) and Sales. what i ...
0
votes
1
answer
1k
views
Read csv file and store content in array using python
i have CSV file as the following:
aa , a1, 1, bb, b1, 11, cc, c1, 111
aa2 , a2, 2, bb2, b2, 22, cc2, c2, 222
aa3 , a3, 3, bb3, b3, 33, cc3, c3, 333
and I need to take the first three content and ...
2
votes
2
answers
252
views
Python or Powershell -- reading csv and sorting and gathering data to be sent in an email
Example csv below to describe what I'm looking at doing
ID,Name,SupervisorName,SupervisorEmail,Action,Column5,Column6,Column7
123,Tim Jones,Sam Burk,[email protected],2,data,data,data
124,Mark ...
1
vote
2
answers
1k
views
How to sort a CSV file by date?
I have been reading several posts (1, 2, 3) about this but I can't make it work yet. I have a (simplified) CSV file like this:
NOMBRE,APELLIDO,ID,NACIMIENTO,FECHAINGRESO,MAILPERSONAL,DEPARTAMENTO
...
0
votes
1
answer
483
views
Sort CSV file by count on column values
May I know how I can sort a csv file by a certain column, not by the value in the column, but the count of rows having the largest number of same values should appear first (or last).
Is it possible ...
0
votes
2
answers
74
views
Sorting csv column by dollar amount then removing duplicates
I have a csv file that looks like:
I have read almost all of the other topics on this but can't figure it out.
I need to read in the file, sort the income column from highest to lowest and then ...
1
vote
1
answer
218
views
Sorting Timestamps inside a CSV file with Python
I'm trying to sort the content of a csv file by the given timestamps but it just doesn't seem to work for me. They are given in such a way:
2021-04-16 12:59:26+02:00
My current code:
from datetime ...
0
votes
1
answer
461
views
Sort CSV File by Timestamp with Python
I'm trying to sort the content of a csv file by the given timestamps but it just doesn't seem to work for me. They are given in such a way:
2021-04-16T12:59:26+02:00
So year-month-day-T-hour-minute-...
0
votes
1
answer
289
views
Sort multiple csv files within a directory by date python
I have multiple .csv files in the same directory called Original and I want to sort all these files per date, descending (the oldest first) - second column. Every file should be sorted and overwrite ...
0
votes
2
answers
39
views
Python: values from csv-list
I create a list from a csv-file with the output of the first line:
from csv import reader
with open('GAB_Trends_210406/GAB_trendHwsCeilingSupplyTempEast_210406.csv', 'r', encoding='utf-8-sig')...
0
votes
1
answer
42
views
Select a subpart of a csv according to another csv
I have a csv which I want to sort the rows according to the columns of another csv.
More precisely, I have a dataframe X whose rows are indexed with a specific column by pandas in the order of ...
0
votes
1
answer
552
views
Python insertion sorting a csv by row
My objective is to use an insertion sort to sort the contents of a csv file by the numbers in the first column for example I want this:
[[7831703, Christian, Schmidt]
[2299817, Amber, Cohen]
[...
2
votes
1
answer
92
views
Python - a single csv file sort using multiple fields and delete rows that are sequential within that file how do I do this using sqlite
Hi I have the code below that work on sorting a csv file that contains multiple rows for each user and has to be sorted by a few columns and date, where if column 2, 3 and 5 are the same in the ...
2
votes
0
answers
146
views
How to sort the rows of an csv file?
Im trying to sort the rows of my csv file.
This is my code:
import os
import csv
my_path = r'c:\data\FF\Desktop\my_files\Zipped'
for file in os.listdir(my_path):
path_file = os.path.join(...
0
votes
0
answers
62
views
How to get sorted input from an csv file?
I have a problem according to taking and fetching input from a CSV file, let's say for example I have a CSV file as follows:-
product_name,category
canon camera,DSLR
hikvision camera,security
cp plus ...
2
votes
1
answer
864
views
Some CSV cells are wrapped in "quotes" while others are not
I am a newbie to Python. I am not able to debug the code. Can someone please guide how to debug?
with open(inputFile, mode='rt') as f:
reader = csv.reader(f, delimiter=',', quotechar='"')
...