windng
Check-in [6a263362aa]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:get_filepath_or_buffer() now returns compression.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:6a263362aa8a5f87ae62fb539bf81d06acf2e8a6
User & Date: goyo 2015-10-19 12:56:33
Context
2015-10-19
13:05
pandas.testing.assert_array_equal() is not available anymore. check-in: 27b68805f6 user: goyo tags: trunk
12:56
get_filepath_or_buffer() now returns compression. check-in: 6a263362aa user: goyo tags: trunk
12:53
Keyword start cannot be '' in pandas.date_range() check-in: 3c239ab4d0 user: goyo tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to windng/io.py.

187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
...
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
        'PRE(hPa)': ('P', 'PRE(hPa)', height, 'avg'),
    }
    default = ('', s, height, '')
    return d.get(s, default)

def read_vortex(filepath_or_buffer, **kwargs):
    """Read Vortex file into DataFrame."""
    f, encoding = get_filepath_or_buffer(filepath_or_buffer)
    meta = read_vortex_metadata(f)
    kwargs.setdefault('header', 0)
    if pd.__version__ <= '0.15.1':
        kwargs.setdefault('skiprows', 2)
    else:
        # Pandas > 0.15.1 skips blank lines automatically.
        kwargs.setdefault('skiprows', 1)
................................................................................
    result.index.name = 'date_time'
    result.columns = names
    return result


def read_vortex_metadata(filepath_or_buffer):
    """Read Vortex file metadata into dictionary."""
    buf, encoding = get_filepath_or_buffer(filepath_or_buffer)
    metadata = collections.OrderedDict()
    linfo = buf.readline().split()[:4]
    for info in linfo:
        item = info.split('=')
        value = float(item[1])
        metadata[item[0]] = value
    return metadata







|







 







|







187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
...
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
        'PRE(hPa)': ('P', 'PRE(hPa)', height, 'avg'),
    }
    default = ('', s, height, '')
    return d.get(s, default)

def read_vortex(filepath_or_buffer, **kwargs):
    """Read Vortex file into DataFrame."""
    f = get_filepath_or_buffer(filepath_or_buffer)[0]
    meta = read_vortex_metadata(f)
    kwargs.setdefault('header', 0)
    if pd.__version__ <= '0.15.1':
        kwargs.setdefault('skiprows', 2)
    else:
        # Pandas > 0.15.1 skips blank lines automatically.
        kwargs.setdefault('skiprows', 1)
................................................................................
    result.index.name = 'date_time'
    result.columns = names
    return result


def read_vortex_metadata(filepath_or_buffer):
    """Read Vortex file metadata into dictionary."""
    buf = get_filepath_or_buffer(filepath_or_buffer)[0]
    metadata = collections.OrderedDict()
    linfo = buf.readline().split()[:4]
    for info in linfo:
        item = info.split('=')
        value = float(item[1])
        metadata[item[0]] = value
    return metadata