Skip to content
This repository was archived by the owner on Jun 11, 2024. It is now read-only.

Commit 5814a80

Browse files
committed
add :meth:atomx.models.Report.csv property that returns the report content as a list
1 parent 6fbbd76 commit 5814a80

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
----------------
33

44
- you can now remove model attributes with `del`
5+
- add :meth:`atomx.models.Report.csv` property that returns the report content as a list
56

67

78
1.1

atomx/models.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3+
import csv
34
import pprint
45
try: # py3
56
from io import StringIO
@@ -182,6 +183,9 @@ def __init__(self, session, query, fast, id, lines, error, link,
182183
if is_ready:
183184
self._is_ready = is_ready
184185

186+
def __repr__(self):
187+
return "Report(id='{}', is_ready={}, query={})".format(self.id, self.is_ready, self.query)
188+
185189
@property
186190
def is_ready(self):
187191
"""Returns ``True`` if the :class:`.Report` is ready, ``False`` otherwise."""
@@ -230,11 +234,18 @@ def get(self, sort=None, limit=None, offset=None):
230234

231235
@property
232236
def content(self):
233-
"""Returns the content (csv) of the `report`."""
237+
"""Returns the raw content (csv) of the `report`."""
234238
if not self.is_ready:
235239
raise ReportNotReadyError()
236240
return self.session.report_get(self)
237241

242+
@property
243+
def csv(self):
244+
"""Returns the report content (csv) as a list of lists."""
245+
if not self.is_ready:
246+
raise ReportNotReadyError()
247+
return list(csv.reader(self.content.splitlines(), delimiter='\t'))
248+
238249
@property
239250
def pandas(self):
240251
"""Returns the content of the `report` as a pandas data frame."""

0 commit comments

Comments
 (0)