SydroCmd Befehle: Unterschied zwischen den Versionen

Aus TALSIM Docs
(Die Seite wurde neu angelegt: „ ==Extract== Extracts strings from each line within an ASCII file. {| class="wikitable" style="width: 50%;" !style="width: 10%"|Argument !style="width: 90%"|D…“)
 
Keine Bearbeitungszusammenfassung
Zeile 7: Zeile 7:
!style="width: 90%"|Description
!style="width: 90%"|Description
|-
|-
|Key
|1
|<code>-extract</code>
|<code>-extract</code>
|-
|-
|1
|2
|sourcefile
|sourcefile
|-
|-
|2
|3
|<code>-string</code> or <code>-pos</code> or <code>-split</code> <br />(<code>-string</code>=search for a string, <code>-pos</code>=select a position, <code>-split</code>=delimits the string)
|<code>-string</code> or <code>-pos</code> or <code>-split</code> <br />(<code>-string</code>=search for a string, <code>-pos</code>=select a position, <code>-split</code>=delimits the string)
|-
|-
|3
|4
|either string or position as a number
|either string or position as a number
|-
|-
|4
|5
|<code>-endstring</code> or <code>-endlen</code> or <code>-array</code>
|<code>-endstring</code> or <code>-endlen</code> or <code>-array</code>
|-
|-
|5
|6
|either a string or the work blank or a position as integer, depending on the previous argument. With <code>-split</code> a comma-separated list of indices is required indicating which items should be saved
|either a string or the work blank or a position as integer, depending on the previous argument. With <code>-split</code> a comma-separated list of indices is required indicating which items should be saved
|-
|-
|6
|7
|targetfile
|targetfile
|}
|}
Zeile 46: Zeile 46:
!style="width: 90%"|Description
!style="width: 90%"|Description
|-
|-
|Key
|1
|<code>-download</code>
|<code>-download</code>
|-
|-
|1
|2
|URL (possibly with spaceholders like <code>{0}</code>
|URL (possibly with spaceholders like <code>{0}</code>
|-
|-
|2
|3
|Arguments separated by a comma filling the spaceholders in the URL
|Arguments separated by a comma filling the spaceholders in the URL
|-
|-
|3
|4
|targetfile
|targetfile
|}
|}
Zeile 70: Zeile 70:
!style="width: 90%"|Description
!style="width: 90%"|Description
|-
|-
|Key
|1
|<code>-replace</code>
|<code>-replace</code>
|-
|-
|1
|2
|sourcefile
|sourcefile
|-
|-
|2
|3
|string to be searched for (see options)
|string to be searched for (see options)
|-
|-
|3
|4
|Replacement string, string to be inserted (see options)
|Replacement string, string to be inserted (see options)
|-
|-
|4
|5
|targetfile (if not given, sourcefile will be overwritten)
|targetfile (if not given, sourcefile will be overwritten)
|}
|}
Zeile 116: Zeile 116:
!style="width: 90%"|Description
!style="width: 90%"|Description
|-
|-
|Key
|1
|<code>-zip</code>
|<code>-zip</code>
|-
|-
|1
|2
|source directory
|source directory
|-
|-
|2
|3
|zipfilename
|zipfilename
|-
|-
|3
|4
|<code>-pattern</code> or <code>-list</code>
|<code>-pattern</code> or <code>-list</code>
|-
|-
|4
|5
|the pattern or a comma-separated list
|the pattern or a comma-separated list
|}
|}
Zeile 148: Zeile 148:
!style="width: 90%"|Description
!style="width: 90%"|Description
|-
|-
|Key
|1
|<code>-unzip</code>
|<code>-unzip</code>
|-
|-
|1
|2
|source directory
|source directory
|-
|-
|2
|3
|source zipfilename
|source zipfilename
|-
|-
|3
|4
|<code>-pattern</code> or <code>-list</code>
|<code>-pattern</code> or <code>-list</code>
|-
|-
|4
|5
|the pattern or a comma-separated list
|the pattern or a comma-separated list
|}
|}

Version vom 22. Juli 2019, 08:14 Uhr

Extract

Extracts strings from each line within an ASCII file.

Argument Description
1 -extract
2 sourcefile
3 -string or -pos or -split
(-string=search for a string, -pos=select a position, -split=delimits the string)
4 either string or position as a number
5 -endstring or -endlen or -array
6 either a string or the work blank or a position as integer, depending on the previous argument. With -split a comma-separated list of indices is required indicating which items should be saved
7 targetfile


Example1
extracts a string from each line within d:\temp\abc.txt which follows directly after val= and ends at the next blank.
SydroCmd -extract d:\temp\abc.txt -string :val= -endstring blank d:\temp\extract.txt
Example 2
extracts a string from each line within d:\temp\abc.txt starting from position 15 with a length of 25 characters.
SydroCmd -extract d:\temp\abc.txt -pos 15 -endlen 25 d:\temp\extract.txt


Download

Downloads a file with a valid URL to the local memory.

Argument Description
1 -download
2 URL (possibly with spaceholders like {0}
3 Arguments separated by a comma filling the spaceholders in the URL
4 targetfile
Example
Downloads a file from the NOAA data archive. Variables are the year, month, day.
SydroCmd -download http://nomads.ncdc.noaa.gov/modeldata/cfsv2_forecast_mm_9mon/{0}/{0}{1}/{0}{1}{2}/{0}{1}{2}00/flxf.01.{0}{1}{2}00.{3}{4}.avrg.grib.grb2 2016,12,02,2016,12 D:\temp\tmp.grb2

Replace

Replaces all strings with a new string within a file. Is able to handle current date information.

Argument Description
1 -replace
2 sourcefile
3 string to be searched for (see options)
4 Replacement string, string to be inserted (see options)
5 targetfile (if not given, sourcefile will be overwritten)

Options

2. Argument
String to be searched for that will be replaced
Format= [KEYWORD|Valid Formatstring|Valid Number,DateInterval}
KEYWORD = CURRENTDATE
Valid Formatstring = possible is yyy, MM, dd, mm
Valid Number= 0, +2, -5 or any other integer (adds/subtracts the number of years, months, days, hours, minutes as given with the number)
DateIntervall= y, M, d, h, m (is used to add the valid number to the date)
Example: {CURRENTDATE|dd|+1,d} with a date 30/12/2017 results in 31
3. Argument
ordinary string or in combination with CURRENTDATE a date in the format yyyyMMDDhhmm or the keyword Now

Examples

Example1
simple with “hallo” replaced by “goodbye”. The sourcefile will be overwritten.
SydroCmd -replace d:\temp\abc.txt hallo goodbye
Example2
with date information
SydroCmd -replace d:\temp\abc.txt CURRENTDATE 201612050000 d:\temp\abcnew.txt
In this example the first argument is CURRENDATE indicating that date information is used. If this string is found it will be replaced by the date given in the next argument (here 5/12/2016 00:00). In the abc.txt the variable to be replaced must be given as follows: {CURRENTDATE|yyyy|+1,y}. This means the result will be ‘2017’, one year added to 2016.

Zip

Zips files into a Zip File Format.

Argument Description
1 -zip
2 source directory
3 zipfilename
4 -pattern or -list
5 the pattern or a comma-separated list
Example 1
Compresses all files in directory d:\temp\ with *.txt-extension to file myfile.zip
SydroCmd -zip d:\temp\ myfile.zip -pattern *.txt
Example 2
Compresses a list of files in directory d:\temp\ with *.txt-extension to file myfile.zip
SydroCmd -zip d:\temp\ myzipfile.zip -list d:\mylist\file1.txt "d:\many files\newfile.doc"


UnZip

UnZips files from a Zip File.

Argument Description
1 -unzip
2 source directory
3 source zipfilename
4 -pattern or -list
5 the pattern or a comma-separated list
Example 1
Unzips all files in directory d:\temp\ and zipfile myfile.zip with the pattern *.txt to d:\
SydroCmd -unzip d:\ d:\temp\myfile.zip -pattern *.txt
Example 2
Unzips a selection of files from d:\temp\ and myzipfile to d:\
SydroCmd -unzip d:\ d:\temp\myzipfile.zip -list d:\mylist\file1.txt "d:\any directory\newfile.doc"
Expamle 3
Unzips all files in the zipfile from d:\temp\ and myzipfile to d:\
SydroCmd -unzip d:\ d:\temp\myzipfile.zip -pattern *.*