Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
1 vote
0 answers
61 views

Add value in dictionary with inner dictionary [duplicate]

Could you please help with the following problem. I have a dictionary with the following structure: {'logtype16777217': {'Table_AmfSetID.csv': [], 'Table_QCI.csv': [], 'Table_body.csv': [], '...
TRP's user avatar
  • 53
0 votes
1 answer
67 views

How do I append a nested dictionary to a CSV file with keys out of order?

I have a nested dictionary in the format: nested_dict = { 'dictA': {'key_1a': 'value_1a', 'key_2a': 'value2a',...}, 'dictB': {'key_2b': 'value_2b', 'key_1b': 'value_1b,...}, ...
rtd730's user avatar
  • 13
-1 votes
1 answer
214 views

How do i read two CSV files, then merge their data, and write to one CSV file in Python?

To clarify, I have 2 CSV files I want to read. First CSV has the following headers: ['ISO3', 'Languages', 'Country Name']. Second CSV has the following headers: ['ISO3', 'Area', 'Country Name'] I want ...
Canuckster's user avatar
0 votes
1 answer
245 views

Update a csv with dict values in a loop without keys

I can make a csv with from a dict ok using csv.Dictwriter but cannot figure out how to make a function to append a new dicts values to the csv file and ensuring that a value is added to the correct ...
Windy71's user avatar
  • 889
-1 votes
1 answer
57 views

Parsing through URL's in CSV file - Python

I have a CSV file of URL's and I'm attempting to write a code to loop through the URLs and append specific variables them I have in a dictionary. Unfortunately, whenever I attempt this using beautiful ...
twelsh97's user avatar
0 votes
2 answers
38 views

Issue Extracting Data from CSV and Appending to Dict

I'm getting an odd result when trying to insert cells of data from a table (a CSV here but could be other tables) into a list of dictionaries. import csv keylist = ["ID", "RN", "PD"] myID = 0 t = [] ...
zarf.snackler's user avatar
-1 votes
3 answers
116 views

Python - Reading the contents of csv in python and appending it

import csv with open("somecities.csv") as f: reader = csv.DictReader(f) data = [r for r in reader] Contents of somecities.csv: Country,Capital,CountryPop,AreaSqKm Canada,Ottawa,35151728,...
TheIllusiveNick 's user avatar
0 votes
1 answer
204 views

python; merge dictionaries with each dictionary in a new column of the output csv file

With the following script, I parse 3 files to one dictionary in python. The dictionaries do not have all similar keys and I want the values of each dictionary in a new column in my output csv file. So ...
Gravel's user avatar
  • 465
1 vote
2 answers
128 views

appending values to Python dictionary

I have a script that reads a CSV file csv file Asset IP Address,Vulnerability Title 50.103.128.11,Partition Mounting Weakness 10.103.128.11,UDP IP ID Zero 10.103.128.11,Root's umask value is unsafe 0....
Hamed Haddadian's user avatar
0 votes
2 answers
1k views

Creating dictionary from CSV file,

For the following CSV File: A,B,C A1,B1,C1 A1,B2,C2 A2,B3,C3 A2,B4,C4 How do I get my dictionary to look like this: {'A1': {'B1': 'C1', 'B2' : 'C2'}, 'A2': {'B3': 'C3', 'B4' : 'C4'}} I'm using ...
ThatRiddimGuy's user avatar
0 votes
2 answers
712 views

How can I create a dynamic dictionaries in Python using a CSV file

The problem is simple, I have a CSV file with four columns I wanted to value of the first column and make that into a dictionary in my python script. I don't want to add values to the dictionary dates ...
b8con's user avatar
  • 629
0 votes
2 answers
121 views

Python - Sometimes an appended row to a CSV file is added to the end of the previous row

Opening an exiting file and writing a dictionary to it sometimes appends the dictionary (being written as a row) to the end of the previous line. How would I setup this code to always prevent that? ...
traggatmot's user avatar
  • 1,463