I am new to VBA so I need your advices. I need to read data from a lot of text files into excel. Text files are like that:
What I have to do is, I need to read every files' all Feature types and parametres actual values. The format of excel should be like that:
I tried some codes by adapting to my situation but I couldn't do. Do you have an advice about how can I do that? Any advice is appreciated.
I'm working on Talend and recently my goal was to parse each sheet of an Excel file to do some different things.
For example, nowadays I'm working on an excel file composed of 4 sheets and I want to replace some values by other values in both sheets. The output file would be the same excel file, composed of its 4 sheets with all the values, including those replaced.
I used tFileExcelWorkbook and tFileExcelSheetList to parse my Excel file, then tFlowIterate to create a global variable (name of sheet) and tReplace to make the search/replace.
But actually I'm stuck.. I really don't know How to make it to create the same excel file, with the same sheets by using that tReplace component.
Do you know what I could do to solve that problem, and more generally how to do to parse sheets of an Excel file ?
Thanks !
Julien
Julien,
Easier way to parse/process sheets in an Excel would be to use a tFileInputExcel and in the "Sheet list" define the sheet names/position that needs to be worked on.
Renju MAthews
Is there some way to write a csv file such that , when opened in MS Excel , it will open in different tabs in the workspace ?
The short answer is, NO.
For that matter, the long answer is NO too.
csv is a continuous run of lines of values separated by commas. each line doesn't even have to have the same number of values etc. there's no concept of workbooks or different "areas" in csv. Excel cannot be cajoled into opening a csv into multiple workbooks...well at least not without writing VBA to parse the csv file yourself.
the oxml or whatever they've ended up calling the xml file spec for office, allows workbooks and is still easy to deal with being text based. Do you have to use csv or can you switch (at least part way through) to xml?
i have data from a csv file. One Column contains Text like "0.2.11" which i need to reformat to "00.02.0011", the leading zeroes and the length of the dot seperated parts are crucial. These are no dates, just random Numbers. How can i reformat those?
Thanks.
I know that this is an insanely long formula, but I believe it will do what you're looking for:
=IF(LEN(IF(ISERR(FIND(".",A1)),A1,LEFT(A1,FIND(".",A1)-1)))=2,IF(ISERR(FIND(".",A1)),A1,LEFT(A1,FIND(".",A1)-1)),"0"&IF(ISERR(FIND(".",A1)),A1,LEFT(A1,FIND(".",A1)-1)))&"."&IF(RIGHT(MID(A1,FIND(".",A1)+1,2))<>".",MID(A1,FIND(".",A1)+1,2),"0"&LEFT(MID(A1,FIND(".",A1)+1,2),1))&"."&IF(LEN(RIGHT(A1,LEN(A1)-FIND("*",SUBSTITUTE(A1,".","*",LEN(A1)-LEN(SUBSTITUTE(A1,".",""))))))=4,RIGHT(A1,LEN(A1)-FIND("*",SUBSTITUTE(A1,".","*",LEN(A1)-LEN(SUBSTITUTE(A1,".",""))))),IF(LEN(RIGHT(A1,LEN(A1)-FIND("*",SUBSTITUTE(A1,".","*",LEN(A1)-LEN(SUBSTITUTE(A1,".",""))))))=3,"0"&RIGHT(A1,LEN(A1)-FIND("*",SUBSTITUTE(A1,".","*",LEN(A1)-LEN(SUBSTITUTE(A1,".",""))))),IF(LEN(RIGHT(A1,LEN(A1)-FIND("*",SUBSTITUTE(A1,".","*",LEN(A1)-LEN(SUBSTITUTE(A1,".",""))))))=2,"00"&RIGHT(A1,LEN(A1)-FIND("*",SUBSTITUTE(A1,".","*",LEN(A1)-LEN(SUBSTITUTE(A1,".",""))))),"000"&RIGHT(A1,LEN(A1)-FIND("*",SUBSTITUTE(A1,".","*",LEN(A1)-LEN(SUBSTITUTE(A1,".",""))))))))
It's probably long enough that you'd have to save this in one of the new Excel formats like .xlsx or .xlsm for it to save. If you have trouble with it let me know, I also have the formula broken out into several cells (or steps) if you need it that way.
There is a shorter (but still ugly) Excel formula using TEXT function for formatting:
=TEXT(MID(A1,1,FIND(".",A1)-1),"00") &"."& TEXT(MID(A1,FIND(".",A1)+1,FIND(".",A1,FIND(".",A1)+1)-FIND(".",A1)-1),"00") &"."& TEXT(RIGHT(A1,LEN(A1)-FIND(".",A1,FIND(".",A1)+1)),"0000")
I would like to point out there are other methods of solving the same problem. If you have lots of big csv files you might consider preprocessing before importing into Excel. For example, doing the same job in awk is trivial:
BEGIN {
while(getline < "e.csv") {
split($1,a,".");
printf("%02d.%02d.%04d\n",a[1],a[2],a[3]);
}
}
Gawk works well with Windows. After installing, you can run it on the Windows or PowerShell command line as .\awk -f x.awk where x.awk is the above code in a text file.