質問編集履歴

4

タイトルを修正しました

2022/06/27 15:05

投稿

tanatomo
tanatomo

スコア19

test CHANGED
@@ -1 +1 @@
1
- Python3 tabulaで抽出したデータをPandasでExcel化する際に全行できない
1
+ Python3 tabulaで抽出したデータをPandasでExcel化する際に全行書きしされない
test CHANGED
File without changes

3

タイトルを修正しました

2022/06/27 15:04

投稿

tanatomo
tanatomo

スコア19

test CHANGED
@@ -1 +1 @@
1
- Python3 tabulaで抽出したデータをPandasでExcel化する
1
+ Python3 tabulaで抽出したデータをPandasでExcel化する際に全行抽出できない
test CHANGED
File without changes

2

「コードの挿入」を使いました

2022/06/27 14:37

投稿

tanatomo
tanatomo

スコア19

test CHANGED
File without changes
test CHANGED
@@ -9,22 +9,23 @@
9
9
   ②-1 tabulaを使ってPDFからデータ抽出
10
10
   ②-2 pandasを使って②-1のデータをエクセルファイルとして保存
11
11
 
12
+ ```Python
12
13
  import pandas as pd
13
14
  import tabula
14
15
  import glob
15
16
 
16
- file = r"■■抽出元フォルダパス■■\*.pdf"
17
+ file = r"■■抽出元フォルダパス■■*.pdf"
17
18
  files = glob.glob(file)
18
19
  print(files)
19
20
 
20
21
  for alfa in files:
21
22
  print(alfa)
22
23
  file_name = alfa[-13:-4]
23
- data = tabula.read_pdf(alfa,lattice=True,pages="2")
24
+ data = tabula.read_pdf(alfa,lattice=True,pages="2")
24
25
  for df in data:
25
26
  display(df)
26
- df.to_excel(r"■■格納先フォルダパス■■\{}.xlsx".format(
27
+ df.to_excel(r"■■格納先フォルダパス■■{}.xlsx".format(file_name),index=False)
27
- file_name), index=False)
28
+ ```
28
29
 
29
30
 
30
31
 

1

コードの表示方法が途中から変わってしまったので修正を試みました

2022/06/26 10:46

投稿

tanatomo
tanatomo

スコア19

test CHANGED
File without changes
test CHANGED
@@ -1,5 +1,5 @@
1
1
  お世話になります。
2
- 国土交通省のHPにある「全国・主要都市圏における高速道路・主要国道の主な区間の交通量増減」-<1.全国>を集計し、全国の交通量の推移を時系列(月別、年単位)整理しようとしています。
2
+ 国土交通省のHPにある「全国・主要都市圏における高速道路・主要国道の主な区間の交通量増減」-<1.全国>を集計し、全国の交通量の推移を時系列で把握しようとしています。
3
3
  ※[リンク内容](https://www.mlit.go.jp/road/road_fr4_000090.html)
4
4
 
5
5
  1)コードについて
@@ -21,7 +21,6 @@
21
21
  print(alfa)
22
22
  file_name = alfa[-13:-4]
23
23
  data = tabula.read_pdf(alfa,lattice=True,pages="2")
24
-
25
24
  for df in data:
26
25
  display(df)
27
26
  df.to_excel(r"■■格納先フォルダパス■■\{}.xlsx".format(
@@ -37,7 +36,6 @@
37
36
  ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-06-26/d53798f6-6a66-45be-86e5-151299fcd3c6.png)
38
37
 
39
38
 
40
-
41
39
  3)お伺いしたいこと
42
40
  ②-2の処理の際に何か足りないものがあるように思われますがわからず困っております。
43
41
  教えて頂くことはできますでしょうか。