def test_rewrite(self): from clldutils.dsv import reader, rewrite tmp = self.tmp_path('test') shutil.copy(FIXTURES.joinpath('tsv.txt').as_posix(), tmp.as_posix()) rewrite(tmp.as_posix(), lambda i, row: [len(row)], delimiter='\t') self.assertEquals(list(reader(tmp))[0], ['2']) shutil.copy(FIXTURES.joinpath('csv.txt').as_posix(), tmp.as_posix()) rewrite(tmp, lambda i, row: row) self.assertEquals(list(reader(tmp)), list(reader(FIXTURES.joinpath('csv.txt'))))
def link(): parser = argparse.ArgumentParser(description="""\ Complete linking of concepts to concept sets. If either CONCEPTICON_GLOSS or CONCEPTICON_ID is given, the other is added.""") parser.add_argument('conceptlist', help='path to conceptlist to complete') args = parser.parse_args() if not os.path.exists(args.conceptlist): args.conceptlist = data_path('conceptlists', args.conceptlist) assert os.path.exists(args.conceptlist) rewrite(args.conceptlist, Linker(os.path.basename(args.conceptlist).replace('.tsv', '')), delimiter='\t')
def link(): parser = argparse.ArgumentParser( description="""\ Complete linking of concepts to concept sets. If either CONCEPTICON_GLOSS or CONCEPTICON_ID is given, the other is added.""") parser.add_argument('conceptlist', help='path to conceptlist to complete') args = parser.parse_args() if not os.path.exists(args.conceptlist): args.conceptlist = data_path('conceptlists', args.conceptlist) assert os.path.exists(args.conceptlist) rewrite( args.conceptlist, Linker(os.path.basename(args.conceptlist).replace('.tsv', '')), delimiter='\t')
def visit(visitor, fname): return rewrite(fname, visitor, delimiter='\t')