Automatically import multiple text files in one worksheet with a separate sheet for every txt file?

valerio misiti

New Member
Joined
Oct 21, 2020
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Dears,

I do not know anything abot VBA stuff and I have to import multiple text files in one worksheet with a separate sheet for every txt file.
Every txt file is more or less like below (I am interested in the lines after the 9th).
Can you help me? It is one day I am struggling with it but the excel options do not allow me to do that

Ablation Date: 062520
Catheter S/N: 00009
Catheter Lot Number: 000000000215817
Control Mode: TEMPERATURE
Treatment State: RF_ON
Z Magnitude: 125
Z Slope: 0.885
Z Phase: -7.1
CI: 0.545
Gen_Time Set_Time Set_Temp Set_P Abl_Time Imped DC_V DC_I Meas_P Meas_V RFI I_D1 IRet1 Phase TRef TC1 TC2 TC3 TC4 TC5 TC6 TComp SetFlow Fluid Pump1
hh:mm:ss s C W s Ohm V mA W V mA mA mA Deg C C C C C C C C ml/min ml rpm
08:58:24 20 60 50.0 0.00 96 1 313 0.3 5 53 19 53 0.0 29.2 33.8 33.9 33.8 34.7 34.6 34.7 34.7 8 73 31
08:58:25 20 60 50.0 1.00 91 12 4232 49.8 70 723 268 735 7.9 26.5 43.9 46.2 42.6 45.0 45.0 45.4 46.2 8 73 36
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
you can try Power Query with From Folder feature, but I'd like to see more than one example, eg. 3-4
Gen_TimeSet_TimeSet_TempSet_PAbl_TimeImpedDC_VDC_IMeas_PMeas_VRFII_D1IRet1PhaseTRefTC1TC2TC3TC4TC5TC6TCompSetFlowFluidPump1
hh:mm:sssCWsOhmVmAWVmAmAmADegCCCCCCCCml/minmlrpm
08:58:24206050.00.009613130.355319530.029.233.833.933.834.734.634.734.787331
08:58:25206050.01.009112423249.8707232687357.926.543.946.242.645.045.045.446.287336


update your profile about Excel version
 
Upvote 0
Thanks a lot. I updated the Excel version (365).
I attach here anothe couple of examples as I do not see any option to attach. Thanks a lot (where I remove the initial 9 lines: they are always more or less the same):
Gen_Time Set_Time Set_Temp Set_P Abl_Time Imped DC_V DC_I Meas_P Meas_V RFI I_D1 IRet1 Phase TRef TC1 TC2 TC3 TC4 TC5 TC6 TComp SetFlow Fluid Pump1
hh:mm:ss s C W s Ohm V mA W V mA mA mA Deg C C C C C C C C ml/min ml rpm
08:57:46 20 60 50.0 0.00 99 1 306 0.3 5 52 19 50 0.0 29.0 33.5 33.7 33.6 34.7 34.6 34.7 34.7 8 68 35
08:57:47 20 60 50.0 1.00 96 13 4080 50.2 71 715 256 719 9.0 26.8 42.6 43.3 42.7 47.0 45.6 44.9 47.0 8 68 35
08:57:48 20 60 50.0 2.00 95 13 4177 50.1 70 731 281 729 12.6 31.4 45.9 47.9 45.9 46.3 45.8 46.2 47.9 8 68 35
08:57:49 20 60 50.0 3.00 93 13 4130 49.6 69 703 284 726 0.0 30.0 44.1 50.0 44.5 48.3 48.6 47.5 50.0 8 69 35

Gen_Time Set_Time Set_Temp Set_P Abl_Time Imped DC_V DC_I Meas_P Meas_V RFI I_D1 IRet1 Phase TRef TC1 TC2 TC3 TC4 TC5 TC6 TComp SetFlow Fluid Pump1
hh:mm:ss s C W s Ohm V mA W V mA mA mA Deg C C C C C C C C ml/min ml rpm
08:58:24 20 60 50.0 0.00 96 1 313 0.3 5 53 19 53 0.0 29.2 33.8 33.9 33.8 34.7 34.6 34.7 34.7 8 73 31
08:58:25 20 60 50.0 1.00 91 12 4232 49.8 70 723 268 735 7.9 26.5 43.9 46.2 42.6 45.0 45.0 45.4 46.2 8 73 36
08:58:26 20 60 50.0 2.00 92 12 4216 49.9 69 728 299 727 7.4 26.9 43.2 46.4 42.0 47.2 47.3 46.7 47.4 8 73 35
08:58:27 20 60 50.0 3.00 88 12 4283 49.9 68 746 339 758 11.9 28.6 46.0 52.7 44.7 46.5 45.4 48.2 52.7 8 73 36

I tried to follow your suggestion (before I had tried to use import from folder directly from excel). I have some problems:
  • the initial 9 lines makes difficult to get the outcome (I guess they make difficult to the software to understand the pattern)
  • even working without those line I am not anle to get the same your outcome
  • I have multiple txt files like that and I would like to create an Excel sheet with multiple sheets each reporting the data from one single txt file (basically every single shhe should have what you did)
 
Upvote 0
  1. don't change original structure of txt files
  2. zip a few (or all) txt files
  3. share this .zip file via onedrive, googledrive or any similar then post link to the shared .zip file here
  4. why each result must be on the separate sheet?
 
Upvote 0
You could also try the legacy Text Import Wizard to import one of the files - it's simpler than Power Query and allows you to specify the start row. Record a macro and the generated VBA can be edited to loop through the folder and import each file into a separate sheet.

I'm not sure if the legacy Text Import Wizard is available in Excel 365. If so, first you must enable it via File tab -> Options -> Data and then run it via Data tab -> Legacy Wizards -> From Text.
 
Upvote 0
  1. don't change original structure of txt files
  2. zip a few (or all) txt files
  3. share this .zip file via onedrive, googledrive or any similar then post link to the shared .zip file here
  4. why each result must be on the separate sheet?
link to test.zip

I hope I did it properly.
I want to have them in different sheet for doing additional calculations later on.
It should work if they are in the same sheet as well but then I would need maybe something to put them in order/separate the content of one ffile from the other.
Thanks a lot for the help
 
Upvote 0
You could also try the legacy Text Import Wizard to import one of the files - it's simpler than Power Query and allows you to specify the start row. Record a macro and the generated VBA can be edited to loop through the folder and import each file into a separate sheet.

I'm not sure if the legacy Text Import Wizard is available in Excel 365. If so, first you must enable it via File tab -> Options -> Data and then run it via Data tab -> Legacy Wizards -> From Text.
thanks a lot for your help.
I did it for one file wityh the Wizard: my problem is now with "Record a macro and the generated VBA can be edited to loop through the folder and import each file into a separate sheet".
I guess you overestimated my Excel skills :). Is it something that you can tell me how to do?ù
Thanks a lot again
 
Upvote 0
It is not economical to create multiple queries separately for each sheet. Maybe it would be better to create a pick list for each log and show only the selected one.

Select
0hh:mm:sssCWs_1OhmVmAColumn1W_2_3V_4mA_5mA_6mA_7DegC_8C_9C_10C_11C_12C_13C_14C_15ml/minmlrpm
08:56:57206050010612830.35481748029.43434.134.2353535.135.186335
08:56:58206050110113404350.1727262627131631.145.346.644.747.24646.747.286335
08:56:5920605029713408249.971704237710031.148.950.343.945.447.547.950.386335
08:57:0020605039813402750736912587138.927.545.648.242.343.84546.848.286335
08:57:0120605049913405049.97370425070613.130.447.349.842.544.345.348.549.886435
08:57:02206050597134088507270323471810.129.549.152.744.747.749.149.752.786435
08:57:0320605069313418450.37175223673518.630.549.349.243.347.750.149.450.186435
08:57:04206050789124288506875530775013.624.952.948.545.546.347.748.852.986435
08:57:0520605088912428050.16974534874311.227.657.450.848.447.445.246.957.486435
08:57:0620605098813418250707222547326.329.84947.345.74847.548.649.286435
08:57:07206050109112418949.56972528872910.531.642.742.439.543.544.645.245.286435
08:57:08206050119413409950717042657185.125.946.447.240.843.644.846.947.286535


Select
15hh:mm:sssCWs_1OhmVmAColumn1W_2_3V_4mA_5mA_6mA_7DegC_8C_9C_10C_11C_12C_13C_14C_15ml/minmlrpm
09:03:11206050108412430649.8687332387493.828.143.44550.859.752.250.759.7810135
09:03:32206050010112910.35491750029.334.134.334.235.135.135.235.2810335
09:03:3220605019713410950.17171627371511.628.948.646.24543.244.945.548.6810335
09:03:332060502931341925070718321732027.25349.648.143.745.648.253810335
09:03:34206050390124222507073233273712.431.555.554.848.84545.14855.5810335
09:03:3520605049013422050.1717313317421430.653.157.847.543.243.644.757.8810335
09:03:3620605059012424149.96973827574010.43146.147.944.747.55050.250.5810335
09:03:37206050690124219506973830173712.428.346.652.743.442.843.644.352.7810335
09:03:3820605078912423549.96872827774003050.35346.746.849.650.453810335
09:03:3920605088912428050.16974425875012.729.847.851.745.947.851.349.851.7810335
09:03:4020605098813421050.170720291742032.94648.843.745.147.147.248.8810435
09:03:41206050108912425350687552957341428.346.955.74545.246.646.955.7810435
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,762
Messages
6,174,351
Members
452,556
Latest member
Chrisolowolafe

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top