Skip to main content
Help us improve Python packaging – donate today!

Read/write lists and maps (two dimensional lists) from/to files.

Project Description

# ListIO

Read/write lists and maps (two dimensional lists) from/to files.

Lists are stored as plain text -- one value per line.

Maps (two dimensional lists) are stored as CSV.

When reading a list or map from a file, lines starting with a hash sign (`#`) are considered to be comments and ignored.

## Installation

Install using setuptools:

```
python setup.py install
```

## Usage

See [tests/test_listio.py](tests/test_listio.py) for a working example.

### Lists

#### Writing

```python
import listio

listio.write_list(
'mylist.txt',
['foo', 'bar', 'baz']
)
```

mylist.txt now contains:

```
foo
bar
baz
```

#### Reading

mylist.txt:

```
First item
second item
foo
# this is a comment
bar
```

```python
import listio

mylist = listio.read_list('mylist.txt')
```

Variable `mylist` now contains an iterator. If we print it:

```python
print(list(mylist))
```

the result is:

```python
['First item', 'second item', 'foo', 'bar']
```

### Maps

#### Writing

```python
import listio

listio.write_map(
'mymap.csv,
[['foo bar', 'baz', 'x'], [1, 2, 3]]
)
```

mymap.csv now contains:

```
foo bar;baz;x
1;2;3
```

### Reading

mymap.csv:

```csv
First column;"second column";3
# this is a comment
"next;item,";foo;bar
```

```python
import listio

mymap = listio.read_map('mymap.csv')
```

Variable `mymap` now contains an iterator. If we print it:

```python
print(list(mymap))
```

the result is:

```python
[['First column', 'second column', '3'], ['next;item,', 'foo', 'bar']]
```

## Contributing

See [NOTICE](./NOTICE) and [LICENSE](./LICENSE) for license information.

Release history Release notifications

This version
History Node

1.0.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
listio-1.0.0-py2.7.egg (3.1 kB) Copy SHA256 hash SHA256 Egg 2.7 Apr 21, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page