Created
February 28, 2019 12:55
-
-
Save bubnenkoff/e14c97ba26bcd298934c3ccf03ac293b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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