Excel → テーブル(Excel To Table) (変換)
サマリ
Microsoft Excel ファイルをテーブルに変換します。
使用法
-
[Excel → テーブル(Excel To Table)] は、Excel Workbook(*.xlsx)および Microsoft Excel 5.0/95 Workbook(*.xls)フォーマットを入力としてサポートしています。
このツールは、表データが縦に並べられていることを前提としています。先頭行は、出力テーブルのフィールド名とみなされます。これらのフィールド名は、エラーが起きたり名前が重複しないよう検証プロセス中に名前を変更できます。データとデータの間に空の列がある場合、それらは維持され、汎用的なフィールド名(たとえば、field_4)が付与されます。
各フィールドのデータ タイプは一致している必要があります。サポートされるデータ タイプは、浮動小数、テキスト、データ、およびブール型です。ただし、ブール型のフィールドは、short integer として格納されます。
構文
ExcelToTable_conversion (Input_Excel_File, Output_Table, {Sheet})
パラメータ | 説明 | データ タイプ |
Input_Excel_File |
変換する Microsoft Excel。 | File |
Output_Table |
出力テーブル。 | Table |
Sheet (オプション) |
インポートする Excel ファイル内の特定のシートの名前。指定しない場合、ワークブックの最初のシートがデフォルトで使用されます。 | String |
コードのサンプル
ExcelToTable(Excel → テーブル)の例(Python ウィンドウ)
次の Python ウィンドウ スクリプトは、イミディエイト モードで ExcelToTable(Excel → テーブル)関数を使用する方法を示しています。
import arcpy
arcpy.env.workspace = "c:/data"
arcpy.ExcelToTable_conversion("data.xls", "outgdb.gdb", "Sheet1")
ExcelToTable(Excel → テーブル)の例 2(スタンドアロン スクリプト)
Microsoft Excel ファイルの各シートを、ジオデータベースの各テーブルにインポートします。
import os
import xlrd
import arcpy
def importallsheets(in_excel, out_gdb):
workbook = xlrd.open_workbook(in_excel)
sheets = [sheet.name for sheet in workbook.sheets()]
print('{} sheets found: {}'.format(len(sheets), ','.join(sheets)))
for sheet in sheets:
# The out_table is based on the input excel file name
# a underscore (_) separator followed by the sheet name
out_table = os.path.join(
out_gdb,
arcpy.ValidateTableName(
"{0}_{1}".format(os.path.basename(in_excel), sheet),
out_gdb))
print('Converting {} to {}'.format(sheet, out_table))
# Perform the conversion
arcpy.ExcelToTable_conversion(in_excel, out_table, sheet)
if __name__ == '__main__':
importallsheets('c:/data/data.xls',
'c:/data/outgdb.gdb')
関連トピック
ライセンス情報
ArcGIS for Desktop Basic: ○
ArcGIS for Desktop Standard: ○
ArcGIS for Desktop Advanced: ○
7/28/2014