Skip to content

Commit

Permalink
add note in docs as well
Browse files Browse the repository at this point in the history
  • Loading branch information
brisvag committed Sep 27, 2023
1 parent 320d3bb commit 69dc805
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions docs/examples/multi_block.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ _rlnNrOfSignificantSamples #21

## Reading
Reading a file with multiple data blocks is similar to reading a file with a single data block.
In this case, a dictionary of dataframes is returned. The keys of this dictionary are the names
In this case, a dictionary of dataframes or dictionaries is returned. The keys of this dictionary are the names
of data blocks.

```python
Expand All @@ -61,14 +61,14 @@ particle_df = star['particles']

!!! tip

`starfile.read` can be forced to always return a dictionary of dataframes.
`starfile.read` can be forced to always return a dictionary of entries.

```python
starfile.read('particles.star', force_dict=True)
```

## Writing
Writing a file containing multiple data blocks is similar, simply pass a dictionary of dataframes.
Writing a file containing multiple data blocks is similar, simply pass a dictionary of entries.

```python
import starfile
Expand Down
8 changes: 7 additions & 1 deletion docs/examples/single_block.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,17 @@ df.head()
4 96.18780 80.12540 204.55875 14.910 163.26 -16.0300 01_10.00Apx.mrc
```


!!! note

Simple data blocks (unlike those using the `loop_` notation) will return a python dictionary instead of a dataframe:


Save the (modified) data to file

```python
starfile.write(df, 'modified_particles.star')
```

For files containing multiple data blocks, please see the
[multiple data block](./examples/multi_block.md) example.
[multiple data block](./examples/multi_block.md) example.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

*starfile* can be used interactively to inspect/explore files or in
scripts and larger software packages to provide basic STAR file I/O functions.
Data is exposed as
Data is exposed as simple python dictionaries or
[pandas dataframes](https://pandas.pydata.org/docs/user_guide/dsintro.html#dataframe).

This package was designed principally for compatibility with files generated by
Expand Down

0 comments on commit 69dc805

Please sign in to comment.