Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,41 +0,0 @@
|
|||
with Ada.Text_IO, Ada.Directories, Ada.Command_Line, Ada.IO_Exceptions;
|
||||
use Ada.Text_IO;
|
||||
|
||||
procedure Remove_Lines_From_File is
|
||||
Temporary: constant String := ".tmp";
|
||||
begin
|
||||
if Ada.Command_Line.Argument_Count /= 3 then
|
||||
raise Constraint_Error;
|
||||
end if;
|
||||
declare
|
||||
Filename: String := Ada.Command_Line.Argument(1);
|
||||
First: Positive := Integer'Value(Ada.Command_Line.Argument(2));
|
||||
Last: Natural := Integer'Value(Ada.Command_Line.Argument(3)) + First - 1;
|
||||
Input, Output: File_Type;
|
||||
Line_Number: Positive := 1;
|
||||
begin
|
||||
Open(Input, In_File, Filename); -- open original file for reading
|
||||
Create(Output, Out_File, Filename & Temporary); -- write to temp. file
|
||||
while not End_Of_File(Input) loop
|
||||
declare
|
||||
Line: String := Get_Line(Input);
|
||||
begin
|
||||
if Line_Number < First or else Line_Number > Last then
|
||||
Put_Line(Output, Line);
|
||||
end if;
|
||||
end;
|
||||
Line_Number := Line_Number + 1;
|
||||
end loop;
|
||||
Close(Input);
|
||||
Close(Output);
|
||||
Ada.Directories.Rename(Old_Name => Filename & Temporary,
|
||||
New_Name => Filename);
|
||||
end;
|
||||
exception
|
||||
when Constraint_Error | Ada.IO_Exceptions.Name_Error =>
|
||||
Put_Line("usage: " & Ada.Command_Line.Command_Name &
|
||||
" <filename> <first> <length>");
|
||||
Put_Line(" opens <filename> for reading and " &
|
||||
"<filename>" & Temporary & " for temporary writing");
|
||||
Put_Line(" requires first > 0, length >= 0");
|
||||
end Remove_Lines_From_File;
|
||||
|
|
@ -8,7 +8,7 @@ removeFileLines: function [filename, start, cnt][
|
|||
]
|
||||
|
||||
final: previous\[0..start-1] ++ previous\[start+cnt..dec size previous]
|
||||
write filename join.with:"\n" final
|
||||
(join.with:"\n" final) >> filename
|
||||
]
|
||||
|
||||
removeFileLines "myfile.txt" 3 10
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
function del-line($file, $start, $end) {
|
||||
$i = 0
|
||||
$start--
|
||||
$end--
|
||||
(Get-Content $file) | where{
|
||||
($i -lt $start -or $i -gt $end)
|
||||
$i++
|
||||
} > $file
|
||||
(Get-Content $file)
|
||||
}
|
||||
del-line "foobar.txt" 1 2
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
Sub remove_lines(filepath,start,number)
|
||||
Set objFSO = CreateObject("Scripting.FileSystemObject")
|
||||
Set InFile = objFSO.OpenTextFile(filepath,1,False)
|
||||
line_count = 1
|
||||
discard_count = 1
|
||||
out_txt = ""
|
||||
Do Until InFile.AtEndOfStream
|
||||
line = InFile.ReadLine
|
||||
If line_count <> start Then
|
||||
If InFile.AtEndOfStream = False Then
|
||||
out_txt = out_txt & line & vbCrLf
|
||||
Else
|
||||
out_txt = out_txt & line
|
||||
End If
|
||||
line_count = line_count + 1
|
||||
Else
|
||||
Do Until discard_count = number
|
||||
InFile.SkipLine
|
||||
discard_count = discard_count + 1
|
||||
Loop
|
||||
line_count = line_count + 1
|
||||
End If
|
||||
Loop
|
||||
InFile.Close
|
||||
Set OutFile = objFSO.OpenTextFile(filepath,2,False)
|
||||
OutFile.Write(out_txt)
|
||||
OutFile.Close
|
||||
Set objFSO = Nothing
|
||||
End Sub
|
||||
|
||||
Call remove_lines("C:\Test.txt",3,4)
|
||||
Loading…
Add table
Add a link
Reference in a new issue