python - 255 个字符,因为它超出了 Excel 对 URLS 的限制
问题描述
我有一个excel。我想读取并更改此 excel 文件,之后我想将此 excel 文件另存为新的 excel 文件。我不得不将 excel 的列更改为字符串,因为在此列中有表情符号。我的问题是当我尝试保存 excel 文件时。
错误信息
with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS
force_unicode(url))
C:\Users\user\AppData\Local\Continuum\anaconda3\lib\site-packages\xlsxwriter\worksheet.py:931: UserWarning: Ignoring URL 'https://stackoverflow.com/...'
我发现了这个代码片段,其他人有同样的问题
writer = pd.ExcelWriter(path+fileName, options={'strings_to_urls': False})
但我不知道如何使用writer
and my df['Content'] = df['Content'].astype(str)
. 如何保存我的excel文件而不会出错?在保存之前,我想把 excel 文件拿出来并改变它。
我的代码
import pandas as pd
path = '/My Documents/Python/'
fileName = "Test.xlsx"
#ef = pd.ExcelFile(path+fileName)
df = pd.read_excel(path+fileName, 'Coded Data')
#writer = pd.ExcelWriter(path+fileName, options={'strings_to_urls': False})
i = 1
for test in df['Content']:
try:
df['Content'] = df['Content'].astype(str)
except:
print("An exception occurred")
break
i += 1
print('success')
df.to_excel('/My Documents/Python/test_NEW.xlsx')
print('success')
先感谢您!期待您的回音。
解决方案
推荐阅读
- sql - 使用动态 SQL 将参数传递给存储过程到透视数据
- laravel - 具有 Laravel 和多对多关系的 Metronic 数据表
- ruby-on-rails - Ruby on rails 从控制器路由到 html 文件
- php - 序列化为 JSON 时 PHP 中的意外行为
- python - 使用循环生成定义范围内的随机数
- delphi - Delphi:使用带有 SSL 和 office365 的 Indy 10 SMTP
- python - 如何使用 python 在带有硒的 DatePicker 中选择日期
- python - 将对象插入特定列表索引
- visual-studio-2013 - 在带有resharper的Vs2013中,左边距的黄线是什么
- kotlin - 我应该在 Kotlin 中使用 Closable.use{...} 处理异常吗?