在损坏的 CSV 中加入并添加双引号

问题描述 投票:0回答:1

我尝试用 python 读取 csv,但我注意到 csv 已损坏并且某些行没有双引号。

示例

ProcessId,nid,CreatedDate,name,uid,Forum,cid,pid,hostname,Change,status,Thread,level,CommentOrder,bundle,deleted,lang,delta,Length_comment_text,field_data_comment_body,topic,isAnswer,CreatedAt,Updatedat,commentText,sticky,CommentRating,CommentRateTimes,Helpfull
1,1031762,2018-01-01 03:42:53,vimo,96977,LoRa®,1031762,0,204.2.166.150,2018-01-01 03:42:53,0,1031762,0,1031762,,0,und,0,1514,comment,How can RN2483 reach -146dBm sensitivity...,0,2018-01-01 03:42:53,2018-01-01 03:42:53,[p]
... if the SX1276 chip inside states to perform -146dBm with a bandwidth of 10.4KHz, while the minimum bandwidth value supported by RN2483 API is 125KHz?

Hi everybody (happy new year!).

According to RN2483 datasheet, its best sensitivity performance in LoRa modulation is -146dBm. However, in order to achieve such a sensitivity, the SX1276 transceiver inside the RN2483 module requires a receive bandwidth of 10.4KHz or less.
Unfortunately, the RN2483 API does only support bw configuration of 500, 250 and 125 KHz. Using a bw value of 125KHz the SX1276 transceiver should be capable to perform a maximum sensitivity of -136dBm.

Am I missing something, or is there actually some trouble with RN2483 datasheet (or command interface) ?

[/p],0,0,0,0

这是我尝试读取 csv 的方式:

with open(pathCsv, encoding="utf-16") as f:
    csv_reader = csv.DictReader(f)
    for row in csv_reader :
        print(row.get('commentText'))
        break

当我迭代 csv 时,我得到了以下输出:

print(row.get('commentText'))
>> [p]

我想知道如何再次加入文本并在文本中添加双引号。

python csv
1个回答
1
投票

这适用于问题中显示的数据。如果要处理的 CSV 文件包含多行,则需要采用不同的方法。

from csv import DictReader

with open(pathCsv) as data:
    columns, *content = map(str.strip, data)
    merged = [columns, ''.join(content)]
    for r in DictReader(merged):
        print(r.get('commentText'))

输出:

[p]... if the SX1276 chip inside states to perform -146dBm with a bandwidth of 10.4KHz, while the minimum bandwidth value supported by RN2483 API is 125KHz?Hi everybody (happy new year!).According to RN2483 datasheet, its best sensitivity performance in LoRa modulation is -146dBm. However, in order to achieve such a sensitivity, the SX1276 transceiver inside the RN2483 module requires a receive bandwidth of 10.4KHz or less.Unfortunately, the RN2483 API does only support bw configuration of 500, 250 and 125 KHz. Using a bw value of 125KHz the SX1276 transceiver should be capable to perform a maximum sensitivity of -136dBm.Am I missing something, or is there actually some trouble with RN2483 datasheet (or command interface) ?[/p]
© www.soinside.com 2019 - 2024. All rights reserved.