Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #98743
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Denis McMahon <denismfmcmahon@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Plotting timeseries from a csv file using matplotlib |
| Date | Fri, 13 Nov 2015 14:32:38 -0000 (UTC) |
| Organization | A noiseless patient Spider |
| Lines | 29 |
| Message-ID | <n24sa6$f8n$2@dont-email.me> (permalink) |
| References | <d52cd13c-25e4-4393-8eff-6910c7394f17@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| Injection-Date | Fri, 13 Nov 2015 14:32:38 -0000 (UTC) |
| Injection-Info | mx02.eternal-september.org; posting-host="66ffcfa4470a58bcddbdcd1913f98ab4"; logging-data="15639"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+72q8wLi6FCOTLFu09YsplS455uoJCJ/s=" |
| User-Agent | Pan/0.136 (I'm far too busy being delicious; GIT 926a150 git://git.gnome.org/pan2) |
| Cancel-Lock | sha1:K+NCqoYdqXl1gCVy72lf8ZSGY4U= |
| Xref | csiph.com comp.lang.python:98743 |
Show key headers only | View raw
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