Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #98743
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Plotting timeseries from a csv file using matplotlib |
| Date | 2015-11-13 14:32 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <n24sa6$f8n$2@dont-email.me> (permalink) |
| References | <d52cd13c-25e4-4393-8eff-6910c7394f17@googlegroups.com> |
On Thu, 12 Nov 2015 21:27:58 -0800, Karthik Sharma wrote:
> I have some csv data in the following format. ......
Does the following idea help?
Create a key from the key fields, remove the key fields from the row dic
(so now it's a dic of just the data fields), and save that in the
plotdata dict keyed by the key.
import csv
keybits = ["Ln","Dr","Tag","Lab"]
plotdata = {}
with open("lab.csv", 'r') as fin:
reader = csv.DictReader(fin)
for row in reader:
key = tuple([row[k] for k in keybits])
for k in keybits:
del row[k]
plotdata[key] = row
This generates a dictionary (plotdata) keyed by the key tuples where the
value for each key is a dictionary of 0:0n : value
--
Denis McMahon, denismfmcmahon@gmail.com
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Plotting timeseries from a csv file using matplotlib Karthik Sharma <karthik.sharma@gmail.com> - 2015-11-12 21:27 -0800 Re: Plotting timeseries from a csv file using matplotlib Fabien <fabien.maussion@gmail.com> - 2015-11-13 12:51 +0100 Re: Plotting timeseries from a csv file using matplotlib Denis McMahon <denismfmcmahon@gmail.com> - 2015-11-13 14:32 +0000
csiph-web