fork download
  1. >>> import csv_normal as csv
  2. >>> x = csv.str2csv("""
  3. City name, Area, Population, Annual Rainfall
  4. Adelaide, 1295, 1158259, 600.5
  5. Brisbane, 5905, 1857594, 1146.4
  6. Darwin, 112, 120900, 1714.7""")
  7. >>>
  8. >>> x.trim() #空の行、空の列を削除
  9. >>> x.header_idx=0 #ヘッダーを行指定
  10. >>> x.data_row_range=slice(1,None) #データ範囲を行指定
  11. >>>
  12. >>> x.print2()
  13. +----------+------+----------+----------------+
  14. |City name |Area |Population|Annual Rainfall |
  15. +----------+------+----------+----------------+
  16. |Adelaide | 1_295| 1_158_259| 600.50|
  17. +----------+------+----------+----------------+
  18. |Brisbane | 5_905| 1_857_594| 1_146.40|
  19. +----------+------+----------+----------------+
  20. |Darwin | 112| 120_900| 1_714.70|
  21. +----------+------+----------+----------------+
  22. >>>
  23. >>> #表示フォーマットの調整確認(ヘッダーは中央揃え、Populationのデータも中央揃え、文字幅は全部20)
  24. >>> x.print_chg_format(header_aligns={None:'^'}, aligns={x['Population']:'^'}, widths={None:20})
  25. City name , Area , Population , Annual Rainfall
  26. Adelaide , 1_295, 1_158_259 , 600.50
  27. Brisbane , 5_905, 1_857_594 , 1_146.40
  28. Darwin , 112, 120_900 , 1_714.70
  29. >>>
  30. >>> #表示フォーマットの固定&枠付け
  31. >>> y = x.wrap_border(header_aligns={None:'^'}, aligns={x['Population']:'^'}, widths={None:20})
  32. >>> y.print()
  33. +--------------------+--------------------+--------------------+--------------------+
  34. | City name | Area | Population | Annual Rainfall |
  35. +--------------------+--------------------+--------------------+--------------------+
  36. |Adelaide | 1_295| 1_158_259 | 600.50|
  37. +--------------------+--------------------+--------------------+--------------------+
  38. |Brisbane | 5_905| 1_857_594 | 1_146.40|
  39. +--------------------+--------------------+--------------------+--------------------+
  40. |Darwin | 112| 120_900 | 1_714.70|
  41. +--------------------+--------------------+--------------------+--------------------+
  42. >>>
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Traceback (most recent call last):
  File "/usr/lib/python3.5/py_compile.py", line 125, in compile
    _optimize=optimize)
  File "<frozen importlib._bootstrap_external>", line 735, in source_to_code
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "./prog.py", line 1
    >>> import csv_normal as csv
     ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.5/py_compile.py", line 129, in compile
    raise py_exc
py_compile.PyCompileError:   File "./prog.py", line 1
    >>> import csv_normal as csv
     ^
SyntaxError: invalid syntax

stdout
Standard output is empty