How to dump data from the file to excel sheet through python script? -
i want dump [3-4 lines together] info excel sheet. able dump single line based on criteria [like if line getting start // or /* ], in case of when lines starts /* , after 3-4 sentences end * / . first line started /* , lastly line ended */ able dump. i'm unable handle situation, please help.
below code:-
fileopen = open("test.c") var in fileopen: if var.startswith("//"): var1 = var1 + var go on if var.startswith("/*"): var1 = var1 + var go on else: go on worksheet.write(i, 5,var1,cell_format) note:- above code having indentation issue. don't how set code in stack on flow, please ignore issue.
for example:- /* test right info prefetch instructions generated i386 variants utilize 3dnow! prefetchw or sse prefetch instructions with locality hints. */
i want dump entire info @ 1 time through python script able dump "first line", started /*.
any suggestion please!!! in advance.
import re fileopen = open("test.c") # convert file string source_code = "" var in fileopen: source_code += var # find comments source code pattern = r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"' found = re.findall(pattern, source_code, re.dotall | re.multiline) # list of comments var1 = "" var in found: var1 = var1 + var worksheet.write(i, 5,var1,cell_format)
python excel
No comments:
Post a Comment