Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added -t type option, removed -f subfield option

  • Loading branch information...
commit 9f20b191fc0c6a3987623a7f0bde0b0a338ed20f 1 parent ea51868
Luciano Ramalho ramalho authored
BIN  fixtures/lilacs1/LILACS.cnt
View
Binary file not shown
28 fixtures/lilacs1/LILACS.fdt
View
@@ -0,0 +1,28 @@
+W:LILACS
+F:LILACS
+S:LILACS
+***
+one 1 1000 0 0
+two 2 1000 2 0
+four 4 1000 0 1
+five 5 1000 0 0
+six 6 1000 0 0
+eight 8 1000 0 0
+ten 10 1000 0 1
+twelve 12 1000 0 1
+thirty 30 1000 0 0
+thirty-one 31 1000 0 0
+thirty-two 32 1000 0 0
+thirty-five 35 1000 0 0
+forty 40 1000 0 0
+forty-one 41 1000 0 1
+sixty-four 64 1000 0 0
+sixty-five 65 1000 0 0
+sixty-seven 67 1000 0 0
+eighty-three 83 1000 0 1
+eighty-four 84 1000 0 0
+ninety-one 91 1000 0 0
+ninety-two 92 1000 0 1
+ninety-eight 98 1000 0 0
+one-thirteen 113 1000 0 0
+seven-seven-eight 778 1000 0 0
BIN  fixtures/lilacs1/LILACS.ifp
View
Binary file not shown
35 fixtures/lilacs1/LILACS.iso
View
@@ -0,0 +1,35 @@
+02727000000000409000450000100060000000200070000600400070001300400080002000500020
+00280060003000300080107000330100162001400100145003020100149004470100147005960120
+06000743012006800803030002100871031000200892032000200894035001000896040000300906
+04100030090904100030091206400110091506500090092606700030093508306510093808306350
+15890840011022240910009022350920009022440920004022530980006022571130002022637780
+05202265BR1.1538886LILACSLLXPEDTSasInternet^ihttp://www.demneuropsy.com.b
+r/imageBank/PDF/v3n3a04.pdf?aid2=168&nome_en=v3n3a04.pdf^len.pdfKanda, Paul
+o Afonso de Medeiros^1University of Sao Paulo ^2School of Medicine^3Cognitive Di
+sorders of Clinicas Hospital Reference Center^pBrasil ^cSao Paulo^rorgAnghinah,
+ Renato^1University of Sao Paulo^2School of Medicine^3Cognitive Disorders of Cli
+nicas Hospital Reference Center^pBrasil^cSao Paulo^rorgSmidth, Magali Taino^1Un
+iversity of Sao Paulo^2School of Medicine^3Cognitive Disorders of Clinicas Hospi
+tal Reference Center^pBrasil^cSao Paulo^rorgSilva, Jorge Mario^1University of S
+ao Paulo^2School of Medicine^3Cognitive Disorders of Clinicas Hospital Reference
+ Center^pBrasil^cSao Paulo^rorgThe Clinical use of quantitative EEG in cognitiv
+e disordersA utiliza�ao cl�nica do EEG quantitativo nos transtornos cognitivos
+Dement. neuropsychol331980-5764PtEnEn20/09/200920090000BRAbstract: The
+ primary diagnosis of most cognitive disorders is clinically based, but the EEG
+plays a role in evaluating, classifying and following some of these disorders. T
+here is an ongoing debate over routine use of qEEG. Although many findings regar
+ding the clinical use of quantitative EEG are awaiting validation by independent
+ investigators while confirmatory clinical follow-up studies are also needed, qE
+EG can be cautiously used by a skilled neurophysiologist in cognitive dysfunctio
+ns to improve the analysis of background activity, slow/fast focal activity, sub
+tle asymmetries, spikes and waves, as well as in longitudinal follow-ups.(AU)Re
+sumo: O uso cl�nico do EEG Quantitativo nas doen�as cognitivas. O diagn�stico da
+s doen�as cognitivas geralmente � cl�nico mas o EEG � importante como exame auxi
+liar na avalia�ao, diagn�stico e classifica�ao de algumas delas. O debate atual
+refere-se ao uso cl�nico do EEGq. Embora muitos achados no EEGq ainda aguardem v
+alida�ao, o EEGq pode ser usado cautelosamente em situa�oes espec�ficas e por um
+ neurofisiologista experiente. Nas doen�as cognitivas ele pode contribuir na an�
+lise da atividade de base, em atividades focais lentas ou r�pidas, assimetrias s
+ut�s, pontas e ondas e no acompanhamento longitudinal dos pacientes.(AU)2010-03
+-0520100211BR1876.9EDTFONTEp538886^dBIREME_LLXPEDT^sS1980-5764200900040001
+00015
BIN  fixtures/lilacs1/LILACS.mst
View
Binary file not shown
25 fixtures/lilacs1/LILACS.pft
View
@@ -0,0 +1,25 @@
+f2,cl4,m(3175,-3175)
+"one (1):",tab(3175),v1/
+"two (2):",tab(3175),v2/
+(if p(v4) then 'four (4):',tab(3175),v4/fi)
+"five (5):",tab(3175),v5/
+"six (6):",tab(3175),v6/
+"eight (8):",tab(3175),v8/
+(if p(v10) then 'ten (10):',tab(3175),v10/fi)
+(if p(v12) then 'twelve (12):',tab(3175),v12/fi)
+"thirty (30):",tab(3175),v30/
+"thirty-one (31):",tab(3175),v31/
+"thirty-two (32):",tab(3175),v32/
+"thirty-five (35):",tab(3175),v35/
+"forty (40):",tab(3175),v40/
+(if p(v41) then 'forty-one (41):',tab(3175),v41/fi)
+"sixty-four (64):",tab(3175),v64/
+"sixty-five (65):",tab(3175),v65/
+"sixty-seven (67):",tab(3175),v67/
+(if p(v83) then 'eighty-three (83):',tab(3175),v83/fi)
+"eighty-four (84):",tab(3175),v84/
+"ninety-one (91):",tab(3175),v91/
+(if p(v92) then 'ninety-two (92):',tab(3175),v92/fi)
+"ninety-eight (98):",tab(3175),v98/
+"one-thirteen (113):",tab(3175),v113/
+"seven-seven-eight (778):",tab(3175),v778/
BIN  fixtures/lilacs1/LILACS.xrf
View
Binary file not shown
47 tools/isis2json.py
View
@@ -41,7 +41,7 @@
SUBFIELD_DELIMITER = '^'
INPUT_ENCODING = 'cp1252'
-def iterMstRecords(master_file_name, subfields):
+def iterMstRecords(master_file_name, isis_json_type):
try:
from br.bireme.zeus.master import MasterFactory, Record
except ImportError:
@@ -59,7 +59,7 @@ def iterMstRecords(master_file_name, subfields):
for field in record.getFields():
field_key = str(field.getId())
field_occurrences = fields.setdefault(field_key,[])
- if subfields:
+ if isis_json_type == 3:
content = {}
for subfield in field.getSubfields():
subfield_key = subfield.getId()
@@ -69,7 +69,7 @@ def iterMstRecords(master_file_name, subfields):
subfield_occurrences = content.setdefault(subfield_key,[])
subfield_occurrences.append(subfield.getContent())
field_occurrences.append(content)
- else:
+ elif isis_json_type == 1:
content = []
for subfield in field.getSubfields():
subfield_key = subfield.getId()
@@ -79,22 +79,14 @@ def iterMstRecords(master_file_name, subfields):
content.append(SUBFIELD_DELIMITER+subfield_key+
subfield.getContent())
field_occurrences.append(''.join(content))
+ else:
+ raise NotImplementedError('ISIS-JSON type %s conversion not yet implemented for .mst input' % isis_json_type)
yield fields
mst.close()
-def iterIsoRecords(iso_file_name, subfields):
+def iterIsoRecords(iso_file_name, isis_json_type):
from iso2709 import IsoFile
- def parse(field):
- content = field.value.decode(INPUT_ENCODING,'replace')
- parts = content.split(SUBFIELD_DELIMITER)
- subs = {}
- main = parts.pop(0)
- if len(main) > 0:
- subs['_'] = main
- for part in parts:
- prefix = part[0]
- subs[prefix] = part[1:]
- return subs
+ from subfield import expand
iso = IsoFile(iso_file_name)
for record in iso:
@@ -102,16 +94,21 @@ def parse(field):
for field in record.directory:
field_key = str(int(field.tag)) # remove leading zeroes
field_occurrences = fields.setdefault(field_key,[])
- if subfields:
- field_occurrences.append(parse(field))
+ content = field.value.decode(INPUT_ENCODING,'replace')
+ if isis_json_type == 1:
+ field_occurrences.append(content)
+ elif isis_json_type == 2:
+ field_occurrences.append(expand(content))
+ elif isis_json_type == 3:
+ field_occurrences.append(dict(expand(content)))
else:
- field_occurrences.append(field.value.decode(INPUT_ENCODING,'replace'))
+ raise NotImplementedError('ISIS-JSON type %s conversion not yet implemented for .iso input' % isis_json_type)
yield fields
iso.close()
def writeJsonArray(iterRecords, file_name, output, qty, skip, id_tag,
- gen_uuid, mongo, mfn, subfields, prefix, constant):
+ gen_uuid, mongo, mfn, isis_json_type, prefix, constant):
start = skip
end = start + qty
if not mongo:
@@ -121,7 +118,7 @@ def writeJsonArray(iterRecords, file_name, output, qty, skip, id_tag,
ids = set()
else:
id_tag = ''
- for i, record in enumerate(iterRecords(file_name, subfields)):
+ for i, record in enumerate(iterRecords(file_name, isis_json_type)):
if i >= end:
break
if i > start and not mongo:
@@ -192,12 +189,8 @@ def writeJsonArray(iterRecords, file_name, output, qty, skip, id_tag,
help='output individual records as separate JSON dictionaries,'
' one per line for bulk insert to MongoDB via mongoimport utility')
parser.add_argument(
- '-f', '--subfields', action='store_true',
- help='explode each field into a JSON dictionary, with "_" as'
- ' default key, and subfield markers as additional keys')
- #parser.add_argument(
- # '-t', '--type', type=int, metavar='ISIS_JSON_TYPE', default=1,
- # help='ISIS-JSON type, sets field structure: 1=string, 2=alist, 3=dict')
+ '-t', '--type', type=int, metavar='ISIS_JSON_TYPE', default=1,
+ help='ISIS-JSON type, sets field structure: 1=string, 2=alist, 3=dict')
parser.add_argument(
'-q', '--qty', type=int, default=DEFAULT_QTY,
help='maximum quantity of records to read (default=ALL)')
@@ -241,7 +234,7 @@ def writeJsonArray(iterRecords, file_name, output, qty, skip, id_tag,
if args.couch:
args.out.write('{ "docs" : ')
writeJsonArray(iterRecords, args.file_name, args.out, args.qty, args.skip,
- args.id, args.uuid, args.mongo, args.mfn, args.subfields, args.prefix, args.constant)
+ args.id, args.uuid, args.mongo, args.mfn, args.type, args.prefix, args.constant)
if args.couch:
args.out.write('}\n')
args.out.close()
7 tools/test.sh
View
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+PYTHONPATH=../isisdm/:$PYTHONPATH
+
+python isis2json.py -t $1 ../fixtures/lilacs1/LILACS.iso
+
+#jython isis2json.py -t $1 ../fixtures/lilacs1/LILACS.mst
Please sign in to comment.
Something went wrong with that request. Please try again.