回答編集履歴
2
コードの改善
test
CHANGED
@@ -19,7 +19,7 @@
|
|
19
19
|
df.to_csv('example.tsv', sep='\t', index=False,
|
20
20
|
encoding='utf-8', quoting=csv.QUOTE_NONE)
|
21
21
|
|
22
|
-
with open('example.tsv') as f:
|
22
|
+
with open('example.tsv', encoding='utf-8') as f:
|
23
23
|
print(f.read())
|
24
24
|
# ID 開始日 終了日
|
25
25
|
# A 2023/01/01 9999/12/31
|
1
文章の改善
test
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
* 「9999/12/31」の変更が可能なら,上限内の「2261/12/31」等に変更する。
|
6
6
|
|
7
|
-
* 所望の形式(YYYY/MM/DD)の TSV ファイルを作成することが主たる目的なら,エクセルファイルから
|
7
|
+
* 所望の形式(YYYY/MM/DD)の TSV ファイルを作成することが主たる目的なら,エクセルファイルから所望の形式の「文字列」として読み込む。文字列で読み込んでも `datetime.date` 型等に後から変換することは可能です。
|
8
8
|
|
9
9
|
2番目について [pandas.read_excel()](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_excel.html) の `converters` パラメータを用いた記述例を下記に示します。なお,環境は「Python 3.12.2, pandas 2.2.1」です。
|
10
10
|
|