Tag: unicode

逗号分隔的LTR / RTL / Digit字符组合重新sorting问题

我有一个从Excel表生成的逗号分隔值列表。 (数字和RTL字符) 在列中具有这些值:1 | 2 | 3 | 4 | 五 会产生1,2,3,4,5的输出 但是,当我在我的列中使用RTL字符(波斯语/阿拉伯语)时,会出现这个问题:1 2بالف和5结尾。 现在输出变成1,2ال,,5 由于我的列可以有多组RTL字符,所以它可以把输出搞得一团糟,通过replace几个input来修复它是不重要的。 我有什么select以正确的顺序产生一个CSV文件? 我使用的工具,其中JavaScript和Excel和两者都有相同的问题。

在python2中处理unicode

#!/usr/bin/env python # -*- coding: utf-8 -*- import tweepy import json import re import sys reload(sys) sys.setdefaultencoding('utf-8') class listener(StreamListener): def on_data(self, data): try: print data tweet = data.split(',"text":"')[1].split('","source')[0] print tweet saveThis = str(time.time())+'::' + tweet saveFile = open("tweetDB3.csv", "a") saveFile.write(saveThis) saveFile.write("\n") saveFile.close() return True except BaseException, e: print "failed ondata,",str(e) time.sleep(5) def on_error(self, status): print […]

replace脚本不能使用unicode txt文件

我正在尝试使用下面的代码在文本文件中用逗号replace所有的选项卡: Const ForReading = 1 Const ForWriting = 2 Const TristateTrue = -1 Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile("C:\Users\Tom\Desktop\CSV.txt", ForReading, TristateTrue) strText = objFile.ReadAll strTab = vbTab strText = Replace(strText, strTab, ",") objFile.Close Set objFile = objFSO.OpenTextFile("C:\Users\Tom\Desktop\CSV.txt", ForWriting, TristateTrue) objFile.Write strText objFile.Close 但是,当为附件运行这个时,我得到错误: 第17行字符1无效的过程调用或参数 此文件是从Excel创build的unicode txt文件。 如果我打开文件并以UTF-8格式保存,我的代码将正常工作。 但是,我找不到在代码中进行这种转换的方式,而且没有出现乱码的结果。 任何人都可以帮我得到我的代码与原始的Unicode文本文件工作或find使用可执行代码(VBA /批处理)将文件转换为UTF-8的方式?

阅读一个excel文件,并创build一个包括波兰语字符的最终文本文件

我需要能够阅读有很多波兰人字符的Excel文件。 然后我需要能够写这个文件保存波兰字符的文本文件。 到目前为止,我只能打开文件写一个,但每次它想写的Unicode值。 正如你可以从我的代码中看到的那样,在我写这个文件之前,我将u'去掉,但unicode的值是另一回事。 当我打开文本文件时,结束了这样的事情 [29178.0,Firma handlowa',Sklep farbiarsko-chemiczny',A-ZET ZHC CIEBIELSKI ZENO',LWOWEK',7880005802.0,CW PS',\ u1491czak Rafa \ u0142',ciebielski1@wp.pl',Nie',',17242.364799999999 ,1061.48,0.061562321196220141,Nie',0.0,1.0] 但是我希望它看起来像这样 29,178 Firma handlowa Sklep farbiarsko-chemiczny A-ZET ZHC CIEBIELSKI ZENO LWOWEK 7880005802 CW PSŁuczakRafałciebielski1@wp.pl Nie wb = xlrd.open_workbook(xl_workbook.xls) #Get the sheet names sheets = wb.sheet_names() sheet1=[] for sheet in sheets: sheet1.append(sheet) #open the first sheet sh = wb.sheet_by_name(sheet1[0]) […]

将Excel代码页1251中的Excel值转换为unicode

我正在通过python来调整一些编码的单元格。 我的代码到目前为止: from xlrd import * from xlwt import * wb = open_workbook('a.xls') s = wb.sheets()[0] for row in range(s.nrows): e = s.cell(row,9).value r = s.cell(row,11).value print e,' ',r.decode('cp1251') 当运行这个代码时,我得到这个错误: Traceback (most recent call last): File "C:\Users\pem\workspace\a\src\a.py", line 17, in <module> print e,' ',r.decode('cp1251') File "C:\Python27\lib\encodings\cp1251.py", line 15, in decode return codecs.charmap_decode(input,errors,decoding_table) File "C:\Python27\lib\encodings\cp1251.py", line […]

使用VBA从Excel电子表格中提取unicode文本

我们从Excel电子表格中的文本生成HTML。 该文本包含国际字符的Unicode代表。 当我们使用VBA来提取文本并将其输出到文件时,它被写为ANSI(ASCII)。 有没有办法使用VBA保存Unicode代表? 布鲁斯

如何使Excel保存为文本文件,支持Unicode,并支持单元格内的多行(alt-enter)?

我的应用程序需要通过文本文件来回传递数据。 我的文本文件将具有Unicode文本,并且还需要有一些指示单元格内的多行(我相信是LF字符(ascii 10))的方式。 Excel可以正确读取我的csv文件。 但是,当我在Excel中保存csv文件时,它将用UnicodereplaceUnicode字符。 所以,尽pipe在Excel中它看起来还是很好的,但是如果我closures了Excel,并用Excel重新打开这个文件,我看到的不是我的Unicode字符。 如果不是将Excel另存为csv,我将其另存为Unicode文本,这会生成制表符分隔的具有Unicode字符的文件。 但是,如果closures文件并使用Excel重新打开该文件,则需要通过一个导入向导来识别单元格中的新行,该向导不会识别LF字符(由alt-enter生成)。 相反,它将LF视为一个新的行。 我怎样才能让Excel保存在单元格内同时支持Unicode和多行的文本格式?

无法正确编码CSV文件?

我有这个确切的问题: https : //www.en.adwords-community.com/t5/Basics-for-New-Advertisers/Character-Encoding-used-by-the-editor/td-p/100244 (t1;博士:试图上传文件到谷歌,包含外国字符,他们看起来很有趣,当在Excel中打开,谷歌拒绝他们没有正确编码) 我有以下代码。 请注意,我已经尝试在http响应对象的开头添加一个字节顺序标记,并尝试将所有string编码为utf-8。 <some code where workbook is created and populated via xlwt> output = StringIO.StringIO() workbook.save(output) wb = open_workbook(file_contents=output.getvalue()) sheet = wb.sheet_by_name(spreadsheet) response = HttpResponse(content_type='text/csv') response['Content-Disposition'] = 'attachment; filename='+(account.name+'-'+spreadsheet).replace(',', '')+'.csv' response.write('\xEF\xBB\xBF') writer = csv.writer(response) for rownum in xrange(sheet.nrows): newRow = [] for s in sheet.row_values(rownum): if isinstance(s,unicode): newRow.append(s.encode("utf-8")) elif isinstance(s, […]

在Excel工作表中写阿拉伯文?

我想用Delphi写一个Excel表格中的阿拉伯文字。 当我在纸上写字时,我就得到了这样的东西。 另外,如何从Delphi代码中更改Excel数据types?

VBA Excelmacros编写文件使用UTF-8编码

我在Excel中创build一个处理电子表格并将内容(文本)写入文件的macros。 我需要这个文件被编码为UTF-8。 我已经尝试使用OpenTextFile(… TristateTrue)和StrConv(.. vbUnicode)作为unicode打开文件,但只能将其转换为UTF-16。 我在网上到处search,找不到任何东西。 这甚至有可能吗? 谢谢