Skip to content

Instantly share code, notes, and snippets.

@bubnenkoff
Created February 28, 2019 12:55
Show Gist options
  • Save bubnenkoff/e14c97ba26bcd298934c3ccf03ac293b to your computer and use it in GitHub Desktop.
Save bubnenkoff/e14c97ba26bcd298934c3ccf03ac293b to your computer and use it in GitHub Desktop.
import std.stdio;
import std.file;
import std.path;
import std.algorithm;
string folder = r"C:\temp2\contracts";
void main()
{
string [] dublicates_list;
foreach(DirEntry file; dirEntries(folder, "*.{xml}", SpanMode.depth))
{
int count = 0;
File f = File(file);
foreach(line; f.byLine)
{
if(line.canFind("<supplier>"))
{
count++;
}
dublicates_list ~= file.name;
}
}
writeln("Done");
struct MyStruct
{
string filename;
string inn;
string kpp;
}
MyStruct [] myStructs;
foreach(d; dublicates_list)
{
File f = File(d);
MyStruct ms;
foreach(line; f.byLine)
{
if (line.canFind("INN"))
ms.inn = line.dup;
if (line.canFind("KPP"))
ms.kpp = line.dup;
ms.filename = d;
myStructs ~= ms;
}
}
File file = File("result.txt", "w+");
foreach(el; myStructs)
{
file.write(el.inn, " ", el.kpp, " ", el.filename);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment