[Solved] Trim multiple items CSV using PowerShell

Got it…..I’m sure there is a cleaner version of my regular expressions but it works. $Keywords=”\sVersion\sis\s.{2,16}”, ‘\sfound’, ‘\sshould.{2,40}’,’\sfile’ $Csv | ForEach-Object { ForEach($keyword in $Keywords){ $_.Results = $_.Results -replace $keyword,” }} $Csv | Export-Csv $FileOut -NoTypeInformation solved Trim multiple items CSV using PowerShell

[Solved] How to merge two CSV files by Python based on the common information in both files?

The following script will create result.csv based on your original sample data (see past edits to question): import csv from collections import defaultdict d_entries = defaultdict(list) with open(‘fileTwo.csv’, ‘r’) as f_fileTwo: csv_fileTwo = csv.reader(f_fileTwo) header_fileTwo = next(csv_fileTwo) for cols in csv_fileTwo: d_entries[(cols[0], cols[1])].append([cols[0], ”] + cols[1:]) with open(‘fileOne.csv’, ‘r’) as f_fileOne, open(‘result.csv’, ‘w’, newline=””) as … Read more

[Solved] Separate a row of strings into separate rows [closed]

Python Power Unleased : import csv,sys filename=”a.csv” with open(filename,’rb’) as csvfile: reader = csv.reader(csvfile,delimiter=”,”) try: for row in reader: if row[1].find(‘,’) == -1: line=”,”.join(row) print line else: for i in range(0,row[1].count(‘,’)+1): line = row[0]+’,’+row[1].split(‘,’)[i]+’,’+row[2].split(‘,’)[i] print line except csv.Error as e: sys.exit(‘file %s, line %d: %s’ % (filename, reader.line_num, e)) solved Separate a row of strings … Read more

[Solved] output file properties like filename, etc in powershell into a csv

Get-ChildItem C:\Windows\System32\ | Select-Object Name,CreationTime,@{n=’MD5′;ex={(Get-FileHash $_.fullname).hash}} Use -Recurse parameter if you want to get files from sub directories also: Get-ChildItem C:\Windows\System32\ -Recurse Use -File parameter if you want to get only files and not folders: Get-ChildItem C:\Windows\System32\ -Recurse -File Type the following command to get the list of all available properties: Get-ChildItem | Get-Member 9 … Read more

[Solved] Converting a large ASCII to CSV file in python or java or something else on Linux or Win7

If you are absolutely certain that each entry is 92 lines long: from itertools import izip import csv with open(‘data.txt’) as inf, open(‘data.csv’,’wb’) as outf: lines = (line[2:].rstrip() for line in inf) rows = (data[1:89] for data in izip(*([lines]*92))) csv.writer(outf).writerows(rows) 1 solved Converting a large ASCII to CSV file in python or java or something … Read more

[Solved] How to Merge CSV Files in PHP, Line by Line

Try this php code (gets the lines with file()).: <?php $csv1 = file(‘csv1.csv’, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $csv2 = file(‘csv2.csv’, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $csv3 = file(‘csv3.csv’, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $lines = max(count($csv1), count($csv2), count($csv3)); $finalcsv = array(); for($i=0; $i<$lines; $i++) { if(isset($csv1[$i])) $finalcsv[] = $csv1[$i]; if(isset($csv2[$i])) $finalcsv[] = $csv2[$i]; if(isset($csv3[$i])) $finalcsv[] = $csv3[$i]; } file_put_contents(‘final_data.csv’, implode(PHP_EOL, … Read more

[Solved] Extract gz and convert csv to xlsx

While I agree the OP does not appear to have done their fair share of figuring this out (how hard is Google?), I know someone else will be looking in the future. Posting information will help them. @OP, I’m not going to do all your file handling work for you but here is the basic … Read more

[Solved] Exclude column 0 (rownames) column from data frame and csv output

You can drop the rownames of a dataframe by simply setting them to null. They’re null by default (see ?data.frame), but sometimes they get set by various functions: # Create a sample dataframe with row.names a_data_frame <- data.frame(letters = c(“a”, “b”, “c”), numbers = c(1, 2, 3), row.names = c(“Row1”, “Row2”, “Row3”)); # View it … Read more

[Solved] Conversion of large .csv file to .prn (around 3.5 GB) in Ubuntu using bash

It’s not clear from your question as you didn’t provide sample input/output we could test against but it SOUNDS like all you’re trying to do is this: $ cat tst.awk BEGIN { split(“7 10 15 12 4″,w) FPAT=”[^,]*|\”[^\”]*\”” } { gsub(/””/,RS) for (i=1;i<=NF;i++) { gsub(/”/,””,$i) gsub(RS,”\””,$i) printf “<%-*s>”, w[i], substr($i,1,w[i]) } print “” } $ … Read more

[Solved] Function to read csv string

Here’s how to do what you say you want. Your description of the desired “table” output is somewhat vague, so I made my best guess. def get_rows(data): rows = [] for line in data.splitlines(): fields = line.split(‘,’) if not any(field == ‘NULL’ for field in fields): # Not defective row. rows.append(fields) return rows csv_string = … Read more

[Solved] How to remove first letter if it is number in sql?

You could use the RIGHT() part of the string filtering wher the firts is a number eg: SELECT right(my_column, LENGTH(my_column)-1) FROM my_table WHERE my_column REGEXP ‘^[0-9]’ for update (remove the number ) you could use Update my_table set my_column= right(my_column, LENGTH(my_column)-1) WHERE my_column REGEXP ‘^[0-9]’ 1 solved How to remove first letter if it is … Read more