www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Reading a File

reply Vino <vino.bheeman hotmail.com> writes:
Hi All,

   Need your help, I have file which contains 3 lines, I need to 
ignore the line's which does not have the sign "=", in the blow 
example the 3rd  line(FileName2) and store the result in a array, 
I was able to ignore the line which contains '#" and empty lines 
, but need to help on how to filter the lines which does not have 
the sign "=".

string ConfigFile = Test.txt
#This is a Sample File
FileName1 = test1.txt
FileName2

auto PLines = 
Array!string(File(ConfigFile).byLineCopy().filter!(line => 
!line.all!isWhite && line[0].isAlpha));

From,
Vino.B
Nov 28
parent reply Steven Schveighoffer <schveiguy yahoo.com> writes:
On 11/28/17 1:10 PM, Vino wrote:
 Hi All,
 
    Need your help, I have file which contains 3 lines, I need to ignore 
 the line's which does not have the sign "=", in the blow example the 
 3rd  line(FileName2) and store the result in a array, I was able to 
 ignore the line which contains '#" and empty lines , but need to help on 
 how to filter the lines which does not have the sign "=".
 
 string ConfigFile = Test.txt
 #This is a Sample File
 FileName1 = test1.txt
 FileName2
 
 auto PLines = Array!string(File(ConfigFile).byLineCopy().filter!(line => 
 !line.all!isWhite && line[0].isAlpha));
 
&& line.canFind("=") https://dlang.org/phobos/std_algorithm_searching.html#.canFind -Steve
Nov 28
parent Vino <vino.bheeman hotmail.com> writes:
On Tuesday, 28 November 2017 at 18:34:51 UTC, Steven 
Schveighoffer wrote:
 On 11/28/17 1:10 PM, Vino wrote:
 Hi All,
 
    Need your help, I have file which contains 3 lines, I need 
 to ignore the line's which does not have the sign "=", in the 
 blow example the 3rd  line(FileName2) and store the result in 
 a array, I was able to ignore the line which contains '#" and 
 empty lines , but need to help on how to filter the lines 
 which does not have the sign "=".
 
 string ConfigFile = Test.txt
 #This is a Sample File
 FileName1 = test1.txt
 FileName2
 
 auto PLines = 
 Array!string(File(ConfigFile).byLineCopy().filter!(line => 
 !line.all!isWhite && line[0].isAlpha));
 
&& line.canFind("=") https://dlang.org/phobos/std_algorithm_searching.html#.canFind -Steve
Hi Steve, Thank you very much. From, Vino.B
Nov 28