Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a csv file which contains several columns of data, one of which is datetime and the rest are various values. There are multiple rows for which the datetime is the same and only one of the rest of the columns is different.

I need to be able to have only 1 row for each datetime and fill in each column. I have done this using Visual Studio with a data table but would like to be able to do the same in something outside of VS.

What I have tried:

I've looked for Python applications but can't find a suitable data table method.
Posted
Updated 8-May-22 2:53am
Comments
Richard MacCutchan 29-Apr-22 7:56am    
You can read the data into Excel and manipulate it there.
Maciej Los 29-Apr-22 14:49pm    
Richard, why?
OP should define what language want to use.
Richard MacCutchan 30-Apr-22 3:29am    
Why not? If it works then it is a solution.
Member 11109279 30-Apr-22 4:38am    
The problem is that is works on my computer but there are so many requirements using VS that it hardly ever works when I send it to somebody else and I was looking for a solution other than VS. Preferably Python.
Member 11109279 30-Apr-22 4:43am    
Were talking about hundreds, if not thousands of rows of data. The person responsible for doing this monthly is doing it that way and it's taking way too much time.

You can manipulate Excel data with pandas or A Guide to Excel Spreadsheets in Python With openpyxl – Real Python[^].
 
Share this answer
 
Your requirement is not quite clear. I'd suggest to use pandas.DataFrame[^] with methods:
- read_csv[^]
- drop_duplicates[^].

For example:
Python
#dataframe creation
df = pd.DataFrame({
    'brand': ['Yum Yum', 'Yum Yum', 'Indomie', 'Indomie', 'Indomie'],
    'style': ['cup', 'cup', 'cup', 'pack', 'pack'],
    'rating': [4, 4, 3.5, 15, 5]
})
#removing duplicates:
df.drop_duplicates(subset=['brand'])


#before:
    brand style  rating
0  Yum Yum   cup     4.0
1  Yum Yum   cup     4.0
2  Indomie   cup     3.5
3  Indomie  pack    15.0
4  Indomie  pack     5.0

#after:
    brand style  rating
0  Yum Yum   cup     4.0
2  Indomie   cup     3.5
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900