所以我有下面的文件'14.json',我试图导入到postgres 16数据库的staging表中
现在我不能附加文件..但它的内容在这里:
14.json
{ "ChannelReadings": [
{ "ReadingsDto": [
{
"Si": 47.67,
"Raw": 0,
"Conversion": 0,
"TimeStamp": "2023-01-24T12:57:43"
},
{
"Si": 47.22,
"Raw": 0,
"Conversion": 0,
"TimeStamp": "2023-01-24T13:02:43"
},
{
"Si": 47.6,
"Raw": 0,
"Conversion": 0,
"TimeStamp": "2023-01-24T13:07:43"
},
{
"Si": 47.5,
"Raw": 0,
"Conversion": 0,
"TimeStamp": "2023-01-24T13:12:43"
}
],
"ChannelId": 14
},
{
"ReadingsDto": [
{
"Si": 2.893605,
"Raw": 0,
"Conversion": 0,
"TimeStamp": "2023-01-24T13:07:43"
}
],
"ChannelId": 12
},
{
"ReadingsDto": [
{
"Si": 3.294233,
"Raw": 0,
"Conversion": 0,
"TimeStamp": "2023-01-24T13:07:43"
}
],
"ChannelId": 13
},
{
"ReadingsDto": [
{
"Si": 3.294233,
"Raw": 0,
"Conversion": 0,
"TimeStamp": "2023-01-24T13:07:43"
}
],
"ChannelId": 16
}
],
"DeviceSerialNumber": "894339",
"RestartPointerNo": 5514732,
"NewDownloadTable": false,
"DataHashDto": "5Mckxoq42EeLHmLnimXv6A=="
}
字符串
我的代码如下:
DROP TABLE IF EXISTS tmp;
CREATE TEMP table tmp (
c TEXT
);
COPY tmp FROM 'C:\ChrisDev\Readings\14.json';
型
但我得到以下错误:
[2023-11-16 12:44:32] [22P04] ERROR: extra data after last expected column
[2023-11-16 12:44:32] Where: COPY tmp, line 2: " { "ReadingsDto": ["
型
我试着编辑这个没有用我在这里做错了什么?
1条答案
按热度按时间64jmpszr1#
您的文件中可能有制表符,这对
copy...format text
(默认行为)来说是不幸的,因为copy
附带的另一个默认设置是delimiter
配置为使用制表符:FORMAT
表示要读取或写入的数据格式:text
、csv
(逗号分隔值)或binary
。默认值为text
。DELIMITER
指定文件每行(行)中分隔列的字符。默认值为text
中的 * 制表符 *,CSV
中的逗号。此字符必须是单个单字节字符。使用binary
时不允许使用此选项。要解决这个问题,请尝试另一种方法:
字符串