file-processing

batch file to copy files from one server to other adding remote directory to filename in process

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 04:30:02
问题 I've written a batch file to copy files from one server to another, however, i need to be able to rename the file just copied to contain the folder path. The code i have come up with to do the job is: ECHO OFF SETLOCAL EnableDelayedExpansion set include=*.log FOR /L %%i IN (1,2,3) DO ( net use i: \\my-server%%i\d$\IISLogs FOR /R i:\ %%G IN (%include%) DO ( XCOPY %%G D:\ServerLogsAndBackups\IIS\w%%i\ ) 7z a -t7z D:\ServerLogsAndBackups\IIS\w%%i\files%%i.7z *.log -mx9 net use i: /delete ) The

Process files in pairs

此生再无相见时 提交于 2019-12-08 07:03:03
问题 I have a list of files: file_name_FOO31101.txt file_name_FOO31102.txt file_name_FOO31103.txt file_name_FOO31104.txt And I want to use pairs of files for input into a downstream program such as: program_call file_name_01.txt file_name_02.txt program_call file_name_03.txt file_name_04.txt ... I do not want: program_call file_name_02.txt file_name_03.txt I need to do this in a loop as follows: #!/bin/bash FILES=path/to/files for file in $FILES/*.txt; do stem=$( basename "${file}" ) # stem : file

Perl Program to efficiently process 500,000 small files in a directory

不想你离开。 提交于 2019-12-07 07:16:21
问题 I am processing a large directory every night. It accumulates around 1 million files each night, half of which are .txt files that I need to move to a different directory according to their contents. Each .txt file is pipe-delimited and contains only 20 records. Record 6 is the one that contains the information I need to determine which directory to move the file to. Example Record: A|CHNL_ID|4 In this case the file would be moved to /out/4 . This script is processing at a rate of 80,000

Process files in pairs

自作多情 提交于 2019-12-07 02:58:26
I have a list of files: file_name_FOO31101.txt file_name_FOO31102.txt file_name_FOO31103.txt file_name_FOO31104.txt And I want to use pairs of files for input into a downstream program such as: program_call file_name_01.txt file_name_02.txt program_call file_name_03.txt file_name_04.txt ... I do not want: program_call file_name_02.txt file_name_03.txt I need to do this in a loop as follows: #!/bin/bash FILES=path/to/files for file in $FILES/*.txt; do stem=$( basename "${file}" ) # stem : file_name_FOO31104_info.txt output_base=$( echo $stem | cut -d'_' -f 1,2,3 ) # output_base : FOO31104_info

How to format an output in Python?

浪尽此生 提交于 2019-12-06 09:29:15
I am having difficulty in formatting some code in Python: My code is here: keys = ['(Lag)=(\d+\.?\d*)','\t','(Autocorrelation Index): (\d+\.?\d*)', '(Autocorrelation Index): (\d+\.?\d*)', '(Semivariance): (\d+\.?\d*)'] import re string1 = ''.join(open("dummy.txt").readlines()) found = [] for key in keys: found.extend(re.findall(key, string1)) for result in found: print '%s = %s' % (result[0],result[1]) raw_input() So far, I am getting this output: Lag = 1 Lag = 2 Lag = 3 Autocorrelation Index = #value ...... ...... Semivariance = #value But the desired output I want is: Lag AutoCorrelation

Perl Program to efficiently process 500,000 small files in a directory

两盒软妹~` 提交于 2019-12-05 13:14:34
I am processing a large directory every night. It accumulates around 1 million files each night, half of which are .txt files that I need to move to a different directory according to their contents. Each .txt file is pipe-delimited and contains only 20 records. Record 6 is the one that contains the information I need to determine which directory to move the file to. Example Record: A|CHNL_ID|4 In this case the file would be moved to /out/4 . This script is processing at a rate of 80,000 files per hour. Are there any recommendations on how I could speed this up? opendir(DIR, $dir) or die "$!\n

Printing tokenized data from file in C

感情迁移 提交于 2019-12-05 06:20:09
问题 I've been trying to read in data from a file by tokenizing it first. In this example, I've made it so that it asks you to first input the data in yourself (which I've made sure works), and then read it in but tokenize with spaces. So if I was to enter 'Hello World' it should return: 'Hello, World'. Here's my code. char fname[] = "myfile"; FILE *fp; fp = fopen(fname, "w+"); char buffer[20]; sprintf(prompt, "Enter your string: ", MAX_TAN_INPUT); getString(number, MAX_TAN_INPUT, prompt); printf(

How can I get exactly n random lines from a file with Perl?

混江龙づ霸主 提交于 2019-12-04 06:32:04
Following up on this question, I need to get exactly n lines at random out of a file (or stdin ). This would be similar to head or tail , except I want some from the middle. Now, other than looping over the file with the solutions to the linked question, what's the best way to get exactly n lines in one run? For reference, I tried this: #!/usr/bin/perl -w use strict; my $ratio = shift; print $ratio, "\n"; while () { print if ((int rand $ratio) == 1); } where $ratio is the rough percentage of lines I want. For instance, if I want 1 in 10 lines: random_select 10 a.list However, this doesn't give

Printing tokenized data from file in C

我与影子孤独终老i 提交于 2019-12-03 21:47:36
I've been trying to read in data from a file by tokenizing it first. In this example, I've made it so that it asks you to first input the data in yourself (which I've made sure works), and then read it in but tokenize with spaces. So if I was to enter 'Hello World' it should return: 'Hello, World'. Here's my code. char fname[] = "myfile"; FILE *fp; fp = fopen(fname, "w+"); char buffer[20]; sprintf(prompt, "Enter your string: ", MAX_TAN_INPUT); getString(number, MAX_TAN_INPUT, prompt); printf("\n"); if (fp == NULL) { fprintf(stderr, "Unable to open file %s\n", fname); } else { printf("YAYYY. It

Can I write a file to a folder on a server machine from a Web API app running on it?

眉间皱痕 提交于 2019-12-03 12:24:25
I have this code in my Web API app to write to a CSV file: private void SaveToCSV(InventoryItem invItem, string dbContext) { string csvHeader = "id,pack_size,description,vendor_id,department,subdepartment,unit_cost,unit_list,open_qty,UPC_code,UPC_pack_size,vendor_item,crv_id"; int dbContextAsInt = 0; int.TryParse(dbContext, out dbContextAsInt); string csvFilename = string.Format("Platypus{0}.csv", dbContextAsInt); string csv = string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12}", invItem.ID, invItem.pksize, invItem.Description, invItem.vendor_id, invItem.dept, invItem.subdept