readfile

python 读取 excel

徘徊边缘 提交于 2019-12-04 19:13:00
1.读取文件 2.读取sheetname 3.读取行和列 # -*- coding:utf8 -*- import xlrd from datetime import date, datetime # 读取文件 # 打开文件 xlrd.opem_workbook('file.path.name') readfile = xlrd.open_workbook(r"D:\file\1.xlsx") # print(readfile.sheet_names()) # 读取 sheetname sheet2_name = readfile.sheet_names()[1] # print(sheet2_name) sheet = readfile.sheet_by_name('第二个') #读取整行和整列的内容 row_datas = sheet.row_values(1,2) #行在前 ,列在后 print(row_datas) #col_datas = sheet.col_values(2,1) #列在前 行在后 # -*- coding:utf8 -*- import xlrd from datetime import date, datetime # 读取文件 # 打开文件 xlrd.opem_workbook('file.path.name') readfile = xlrd

What's the correct way to use win32file.ReadFile to get the output from a pipe?

时光怂恿深爱的人放手 提交于 2019-12-04 18:56:39
I'm using the pywin32 extensions to access the win32 API under Python. I'm new at doing Windows programming in Python -- I'm a POSIX guy -- so I may be doing things in a bone-headed manner. I'm trying to use the win32file.ReadFile function properly, and I'm having some trouble interpreting the possible result codes. I'm calling the function like this: result, data = win32file.ReadFile(child_stdout_r, 4096, None) I'm reading the output from a child process that I launch. I get good data, but I'm concerned that there may be more data in the pipe than 4096 characters. (And I'd rather do this

Java基础-File类篇、递归篇

前提是你 提交于 2019-12-04 11:02:57
1. File类 1.1 File类介绍 ​ java.io.File 类是文件和目录路径名的抽象表示,主要用于文件和目录的创建、查找和删除等操作。 1.2 构造方法 语法 public File(String pathname) :通过将给定的路径名字符串转换为抽象路径名来创建新的 File实例。 public File(String parent, String child) :从父路径名字符串和子路径名字符串创建新的 File实例。 public File(File parent, String child) :从父抽象路径名和子路径名字符串创建新的 File实例。 代码 // 创建File对象-方式1 File file1 = new File("D:\\JavaCode\\BasicCode\\a"); System.out.println(file1); // 创建File对象-方式2 File file2 = new File("D:\\JavaCode\\BasicCode\\a","1.txt"); System.out.println(file2); // 创建File对象-方式3 File file3 = new File(file1,"1.txt"); System.out.println(file3); 注意事项

Java基础-File类篇、递归篇

断了今生、忘了曾经 提交于 2019-12-04 11:01:08
1. File类 1.1 File类介绍 ​ java.io.File 类是文件和目录路径名的抽象表示,主要用于文件和目录的创建、查找和删除等操作。 1.2 构造方法 语法 public File(String pathname) :通过将给定的路径名字符串转换为抽象路径名来创建新的 File实例。 public File(String parent, String child) :从父路径名字符串和子路径名字符串创建新的 File实例。 public File(File parent, String child) :从父抽象路径名和子路径名字符串创建新的 File实例。 代码 // 创建File对象-方式1 File file1 = new File("D:\\JavaCode\\BasicCode\\a"); System.out.println(file1); // 创建File对象-方式2 File file2 = new File("D:\\JavaCode\\BasicCode\\a","1.txt"); System.out.println(file2); // 创建File对象-方式3 File file3 = new File(file1,"1.txt"); System.out.println(file3); 注意事项

Out of memory error archiving a log file

試著忘記壹切 提交于 2019-12-04 06:56:40
问题 I am having a problem with a console job that runs and creates a daily log file that I archive at midnight. This creates a blank log file for the next day and an archived file with yesterdays date in the name and the contents of the old file for debugging issues I may have had and not known about until the day after. However since I cranked up the BOT's job I have been hitting issues with System Out of Memory errors when I try and archive the file. At first I was just not able to get an

error: cannot find symbol array.add(element);

爱⌒轻易说出口 提交于 2019-12-04 06:52:08
问题 I have a program that reads from a file, takes each word and adds it to an array as a String. I'm having a bit of trouble with adding the Strings to the array. I get the error: SortingWords.java:73: error: cannot find symbol array.add(element); ^ symbol: method add(String) location: variable array of type String[] I have checked my spelling and all seems to be okay. What is happening and how can I fix it? public class SortingWords { //global variables public static int count = 0; public

Removing brackets and quotes from print in Python 2.7

天大地大妈咪最大 提交于 2019-12-04 06:50:44
问题 I am trying to remove the brackets from the print statement using Python 2.7 I tried suggestions from various forums but it didn't work as expected finally thought of asking out here myself. Code: with open('buttonpress_and_commandstarted','r') as buttonpress_commandstarted: for line in buttonpress_commandstarted: button_press_command_time = '' if os.path.getsize('buttonpress_and_commandstarted') > 0: button_press_command_time = line.split()[2] else: print " > Cannot get time stamp as the

NodeJS readFile() retrieve filename

こ雲淡風輕ζ 提交于 2019-12-04 05:49:17
I am iterating over an array which contains filenames. For each of them, I invoke readFile() . When the corresponding callback is invoked, I wish to retrieve the filename passed to readFile() as a parameter. Can it be done? Enclosed a snipped code to better explain my intention. var fs = require("fs"); var files = ["first.txt", "second.txt"]; for (var index in files) { fs.readFile(files[index], function(err, data) { //var filename = files[index]; // If I am not mistaken, readFile() is asynchronous. Hence, when its // callback is invoked, files[index] may correspond to a different file. // (the

ReadFile function returns ERROR_INVALID_PARAMETER

二次信任 提交于 2019-12-03 21:57:01
I'm trying to get to work ReadFile function. Here's my code: #define BUFFERSIZE 5 int main(int argc, char* argv[]) { OVERLAPPED overlapIn = {}; HANDLE tHandle; char buf[BUFFERSIZE] = {}; DWORD lpNumberOfBytesRead; tHandle = CreateFile( L"\\\\.\\D:", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (tHandle == INVALID_HANDLE_VALUE) { DWORD error = GetLastError(); assert(0); } if (ReadFile(tHandle, &buf, BUFFERSIZE - 1, &lpNumberOfBytesRead, NULL) == 0) { int error = GetLastError(); printf("Terminal failure: Unable to read from disk.\n GetLastError=%d\n",

Java: Read array of integers from file

萝らか妹 提交于 2019-12-03 13:07:54
问题 Say i have a file called "input.txt" that has a bunch of positive integers in it: 6 5 6 8 6 2 4 and so on....(one integer per line) I want to read this file and make it into an array. The first integer (in this case 6) tells the number of indexes or elements in the array, so 6 spots. The other numbers fill in the array starting at 0. So at index 0, the number is 5, at index 1 the number is 6, and so on. Can someone please show me how to read this file and make it into an array called A and