Tag: python

递增函数参数variables

我正在尝试编写一个从Excel文件读取的脚本作为模板,然后根据从.txt文件读取的内容插入新的数据。 我正在使用xlrd模块进行阅读。 目前,我被困在脚本的阅读部分。 我打算每次将colx和colx参数variables加1,以便在Excel文件中search每个单元格。 但是,似乎Python的参数variables不能被修改? 我的脚本增量修改外部variables。 有没有办法实现逐个单元格的值search? # Define variables switch1 = 1 count = 0 rowx = 0 colx = 0 # Loop while switch1 == 1 and count < totalCells: print "AAAA" cellValue = "Long string in here….." if sh.cell_value(rowx=0, colx=0) == cellValue: print "BBBB" switch1 = 0 rowx += 1 colx += […]

在Python(或Excel)中同步数据

我经常使用Python(偶尔Excel)来处理和比较多个实验之间的testing数据。 在某些情况下,数据可能不同步,这使得直接比较困难。 例如,典型的testing规范是: 1) Stabilize test temperature to a value of 20 +/- 2 degrees C 2) Hold test temperature at stabilized value for 15-25 seconds 3) Increase temperature by 20 degrees C at a rate of 0.5 degree C/second 对数据进行归一化是非常简单的,因此它们在时间= 0秒时都以20℃的标称温度值开始,但是我真正想要的是同步数据,使得温度斜坡同时开始。 我已经尝试了简单的algorithm来检查数据的斜率,以确定何时开始温度boost,但由于仪器导致的测量结果的局部波动导致的斜率实际上并不能反映整体温度变化率。 在Numpy,Scipy,Pandas等有function可以过滤掉这些局部波动,并确定何时实际开始增加温度。 我偶尔会在Excel中工作,所以如果在电子表格中有更方便的方法,我可以使用Excel来处理数据。 任何build议,将不胜感激。

在Django中获取多个checkbox的值

我有一张桌子,里面显示不同客户的不同账单: 我在我的views.py中有这样的代码: @login_required def descarga(request,id_factura): selected_values = request.POST.getlist('factura') if request.method == 'POST': form = Factura.objects.filter(id__in=selected_values) if form: (…Styling of the Excell file…) # write the header header = ['Cliente', 'Fecha de Factura', 'Tipo de Factura', 'Numero de Factura', 'Descripcion', 'Subtotal', 'IVA', 'Precio'] for hcol, hcol_data in enumerate(header): # [(0,'Header 1'), (1, 'Header 2'), (2,'Header 3'), […]

详细AttributeError:'模块'对象没有属性'工作簿'

我不断收到Detail AttributeError: 'module' object has no attribute 'workbook'错误。 下面是我的代码 import xlwt workbook = xlwt.workbook() sheet = workbook.add_sheet('Eswar') sheet.write (4,4,'Test passed') workbook.save("D:\resultsLatest.xls") 我做错了什么? 我正在使用Python 2.7

在Windows上使用pywin32 / excel移植Python到Vagrant机器上的Linux

我写了一个广泛的python包,利用excel和pywin32。 我现在正在将这个软件包移动到一个Vagrant机器上的Linux环境中。 我知道有一些“emulator-esque”软件包(例如WINE)可以运行Windows应用程序,并且对于某些Windows应用程序(例如Excel到OpenOffice)来说,它们看起来很像。 然而,我并没有看到正确的道路,为了让我的pywin32 / Excel的依赖代码在Vagrant机器上运行在Linux环境下运行。 理想情况下,我不需要改变我的代码,只需在我的Vagrant机器上进行适当的安装即可。 谢谢

Python / Excel – 将.xlsx工作簿从文件合并到.csv中

试图将多个.xlsx工作簿从一个文件编译为一个.csv文件 我创build的循环只捕获文件中的第一个工作簿。 我怎样才能改变这个捕获文件中的所有工作簿? 数据仅在所有工作簿的Sheet1上 import os import xlrd import csv rootdir = r'C:\Users\username\Desktop\Mults' filenames = [] for subdir, dir, files in os.walk(rootdir): for file in files: filenames.append(os.path.join(subdir, file)) wb = xlrd.open_workbook(os.path.join(subdir, file)) sh = wb.sheet_by_index(0) with open('acit_multsTEST.csv','wb') as f: c = csv.writer(f) for r in range(sh.nrows): c.writerow(sh.row_values(r)) 我感谢任何帮助! 谢谢!

如何使用python将数据写入CSV文件?

我正在试图把下面的数据写入一个csv文件。数据是雇用的细节 名1 – surname1-PLACE1 名2-surname2-place2 NAME3-surname3-place3 NAME4-surname4-place4 我希望输出在一个在另一个下面的CSV文件在不同的行上。 我写了下面的代码 阅读器= csv.reader(文件) op = open(path+“op.CSV”,“wb”) String = list [0] +“ – ”+ list [1] +“ – ”+ list [2] +“ – ”+ list [4] op.writer(String) 请帮忙。 提前致谢。 -KD

在Excel中将表格转换为列表

我有许多excel表格,其中的数据排列在表格中,如下所示 我想把这个表格转换成另一个类似列表的格式,如下所示。 在这个表格中: Dir -> Name of the tab Year -> Same for entire table DOM -> Day of the month DOW -> Day of the week. Hour -> Column label in original table Traffic Count -> Value in the original table 有近1000张这样的床单。 每张表中的数据位于相同的位置。 做这个的最好方式是什么? 我应该写一个VBA脚本还是Excel中有什么东西可以用来让我的生活更轻松?

如何在代码中改变date系统

我有两个excel电子表格需要整理。 一个使用1900基准年系统,另一个使用1904.我用数据填充1904电子表格,然后拉入1900页。 我想将date系统更改为基于1900年填写的第一张表,以便当我拉另一张表时它不会搞砸date。 我无法find神奇的单词,以编程方式在Excel中更改此设置。 我会采取任何语言,任何模块(但我使用win32com和python)。 我可以从那里弄清楚。 这甚至有可能吗? 以下是手动执行的说明: http://answers.microsoft.com/en-us/office/forum/office_2007-excel/why-does-excel-2007-change-dates-when-i-copy-and/b0544a7f-bd82-4b5a-a843- e6ae22f2ef63

将string写入新行

我有用户名+姓氏+分数写在excel文件中的代码。 但是我希望它有标题,例如第一行的“名字”“姓”和“分数”。 然后每次代码重新启动,我想新的数据存储在这些标题下的新列。