在断开的CSV中连接并添加双引号

wfypjpf4  于 2022-12-25  发布在  其他
关注(0)|答案(1)|浏览(185)

我试着用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]

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

x759pob2

x759pob21#

这将适用于问题中显示的数据。如果要处理的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]

相关问题