|
From: <li...@us...> - 2008-10-31 05:40:22
|
Revision: 565
http://pyphant.svn.sourceforge.net/pyphant/?rev=565&view=rev
Author: liehr
Date: 2008-10-31 05:40:11 +0000 (Fri, 31 Oct 2008)
Log Message:
-----------
Introduced FMF-variable 'delimiter', specifying the numpy.loadtxt delimiter.
Modified Paths:
--------------
trunk/src/workers/fmfile/fmfile/FMFLoader2.py
Added Paths:
-----------
trunk/doc/demo/example_delimiter.fmf
Added: trunk/doc/demo/example_delimiter.fmf
===================================================================
--- trunk/doc/demo/example_delimiter.fmf (rev 0)
+++ trunk/doc/demo/example_delimiter.fmf 2008-10-31 05:40:11 UTC (rev 565)
@@ -0,0 +1,56 @@
+# -*- fmf-version: 1.0; coding: utf-8; delimiter: space -*-
+[*reference]
+title: Demonstrating the flexibility of the Full-Metadata-Format
+creator: Andreas W. Liehr
+created: 2008-10-29
+place: Freiburger Materialforschungszentrum, Universität Freiburg, Deutschland
+[String Examples]
+word: Hello!
+sentence: Hello World!
+comma separated list: world, die Welt, el mundo, monde
+multiline: '''A multiline value,
+that spans more than one line :-)
+The line breaks are included in the value.'''
+[Numbers]
+#Note, that the 'key' is arbitrary, but has to be unique within a section
+integer: 1
+float: 1.0
+float with leading dot: .1
+float with exponential: 1e-10
+float with Exponential: -1.1E10
+complex: 1+2j
+[Physical Quantities]
+number: N = 2
+voltage: U = 1V
+temperature in Celsius: T_C = 22 degC
+temperature in Fahrenheit: T = 22 degF
+[Physical Quantities with error]
+voltage: U = 1 V +- 1 mV
+current: I = 1 A +/- 0.001 A
+energy: E = 1 J \pm 1 mJ
+work: A = 1 W +- 0.1%
+voltage in brackets: U = (1 +- 0.001) V
+current in brackets: I = (1 +- 0.1%) A
+estimated parameter: p = 1 \pm 0.1
+another estimated parameter: p = 1 \pm 1%
+[*table definitions]
+table: T
+mixed: M
+[*data definitions: T]
+String: S
+Integer: I
+Float with dot: Fd
+Float with exponent: Fe
+Complex: C
+Missing Value: V_m
+Infinite Value: V_i
+[*data: T]
+H_2 1 1. 1e1 1+0j nan inf
+O_2 2 .2 2E1 2+.1j NaN INF
+[*data definitions: M]
+String: S
+Complex: C
+Float: F
+[*data: M]
+N_2 1 2
+2 1+1j 2.1
Modified: trunk/src/workers/fmfile/fmfile/FMFLoader2.py
===================================================================
--- trunk/src/workers/fmfile/fmfile/FMFLoader2.py 2008-10-31 05:39:41 UTC (rev 564)
+++ trunk/src/workers/fmfile/fmfile/FMFLoader2.py 2008-10-31 05:40:11 UTC (rev 565)
@@ -377,13 +377,16 @@
def preParseData(b):
- localVar = {'fmf-version':'1.0','coding':'cp1252'}
+ localVar = {'fmf-version':'1.0','coding':'cp1252',
+ 'delimiter':'\t'}
commentChar = ';'
if b[0] == ';' or b[0] == '#':
commentChar = b[0]
items = [var.strip().split(':') for var in b.split('-*-')[1].split(';')]
for key,value in items:
localVar[key.strip()]=value.strip()
+ if localVar[key.strip()]=='space':
+ localVar[key.strip()] = ' '
d = unicode(b, localVar['coding'])
dataExpr = re.compile(ur"^(\[\*data(?::\s*([^\]]*))?\]\r?\n)([^[]*)", re.MULTILINE | re.DOTALL)
commentExpr = re.compile(ur"^%s.*"%commentChar, re.MULTILINE)
@@ -391,7 +394,11 @@
preParsedData = {}
def preParseData(match):
try:
- preParsedData[match.group(2)] = numpy.loadtxt(StringIO.StringIO(match.group(3)), unpack=True, comments=commentChar,dtype='S',delimiter='\t')
+ preParsedData[match.group(2)] = numpy.loadtxt(StringIO.StringIO(match.group(3)),
+ unpack=True,
+ comments=commentChar,
+ dtype='S',
+ delimiter=localVar['delimiter'])
except Exception, e:
return match.group(0)
return u""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|