How to import data from text files into Excel?

I have several folders. There are several txt files inside this folder. I need to extract data (only one value: value ---> 554) from a specific txt file type in this folder. ( individual_values.txt)

No  100    Value   555      level match   0.443        top level  0.443       bottom 4343

There will be many folders with the same txt file names, but the value is diff. Can all of these values ​​be copied to succeed one below the other.

I need to extract the value from the txt file that I mentioned above. This is the same text file with the same name, which is located in different folders. All I want to do is extract this value from the entire text file and paste it into excel or txt one below the other on each line.

For example: the text file above should get a value of 555 and similarly to other diff values.

555

666

666

776
+3
6

.

( )

+8

, , , .

, script, , , Comma (CSV). CSV Excel.

+5

, , Excel.

  • OLE- Excel.
  • Excel, .

, 1) , 2) , . , Excel .

Perl:

use IO::File;

my @field_names = split m|/|, 'No/Value/level match/top level/bottom';
#' # <-- catch runaway quote

my $input    = IO::File->new( '<data.txt' );
die 'Could not open data.txt for input!' unless $input;

my @data_rows;
while ( my $line = <$input> ) { 
    my %fields = $line =~ /(level match|top level|bottom|Value|No)\s+(\d+\S*)/g;
    push @data_rows, \%fields if exists $fields{Value};
}

$input->close();

my $tab_file = IO::File->new( '>data.tab' );
die 'Could not open data.tab for output!' unless $tab_file;

$tab_file->print( join( "\t", @field_names ), "\n" );
foreach my $data_ref ( @data ) { 
    $tab_file->print( join( "\t", @$data_ref{@field_names} ), "\n" );
}

$tab_file->close();

. Excel . ( \t ) - :

1\t2\t3\t=SUM(A1:C1)

+4

#, , . csv, .

    string root_path = @"c:\Temp\test";
    string match_filename = "test.txt";

    Func<string,string,StringBuilder, StringBuilder> getdata = null;

    getdata = (path,filename,content) => {
        Directory.GetFiles(path)
        .Where(f=>
            Path.GetFileName(f)
            .Equals(filename,StringComparison.OrdinalIgnoreCase))
        .Select(f=>File.ReadAllText(f))
        .Select(c=> Regex.Match(c, @"value[\s\t]*(\d+)",
            RegexOptions.IgnoreCase))
        .Where(m=>m.Success)
        .Select(m=>m.Groups[1].Value)
        .ToList()
        .ForEach(m=>content.AppendLine(m));
        Directory.GetDirectories(path)
            .ToList()
            .ForEach(d=>getdata(d,filename,content));
                return content;
    };
    File.WriteAllText(
        Path.Combine(root_path, "data.csv"),
        getdata(root_path, match_filename, new StringBuilder()).ToString());
+1

.

, 50/50

(assuming this is a question that answered “Yes” and “No”) hehehe

0
source

FILE_NOT_FOUND

Must have all three binary states to respond.

0
source

Source: https://habr.com/ru/post/1714558/


All Articles