我需要帮助解决这个问题
我使用python 2.7
cat r0_v4-aver.csv
134323
cat u3_v4-aver.csv
127757
cat u3_v4-aver.csv
153126
f_r0v4 = "/home/ubuntu/script/prtg/report-wyze/csv/r0_v4-aver.csv"
f_u3v4 = "/home/ubuntu/script/prtg/report-wyze/csv/u3_v4-aver.csv"
f_t1v4 = "/home/ubuntu/script/prtg/report-wyze/csv/t1_v4-aver.csv"
f_g1_v4 = [ f_r0v4,f_u3v4,f_t1v4 ]
f_g1all_v4 = "/home/ubuntu/script/prtg/report-wyze/csv/g1_all_v4.csv"
o_g1_all_v4 = csv.writer(open(f_g1all_v4, 'wb' ))
for k_g1_v4 in f_g1_v4:
o_g1_v4 = csv.reader(open(k_g1_v4, 'rb'))
t_g1_v4 = o_g1_v4.next()
o_g1_all_v4.writerow(t_g1_v4)
输出
我需要显示的是135285,127362,15540
不显示
134323
127757
153126
谢谢
答案 0 :(得分:0)
尝试一下:只需替换
export class MyClass {
private value;
private valueSubject: Subject<any> = new Subject<any>();
public doSomethingAsync() {
someAsyncCall()
.subscribe(value => {
this.value = value;
this.valueSubject.next(value);
});
return valueSubject.asObservable();
}
}
export class MyOtherClass {
public doSomethingElse() {
const myObj = new MyClass();
let myValue;
myObj
.doSomethingAsync()
.subscribe(value => {
myValue = value
});
}
}
使用
o_g1_all_v4.writerow(t_g1_v4)
注意:您需要创建没有csv模块的o_g1_all_v4.write(t_g1_v4 + ",")
文件,例如:
o_g1_all_v4
,然后在其上使用o_g1_all_v4 = open(<filename.csv>,"w">)
方法。
答案 1 :(得分:0)
不起作用
var rg = '/[^\\](\\n)/g'
var str = 'so you can do pretty much \\nanything you want with it. \n\nAt runtime Carota has'
AttributeError:'_csv.writer'对象没有属性'write'
答案 2 :(得分:0)
o_g1_all_v4 = (open(f_g1all_v4, 'w'))
o_g1_v4 = csv.reader(open(k_g1_v4, 'r'))
t_g1_v4 = o_g1_v4.next()
o_g1_all_v4.write(str(t_g1_v4 + ','))
cat csv / g1_all_v4.csv
['134323'],['127757'],['153126'],
会发生什么?