2014-08-12

Regular expressions for CSV files

SQL Server Import had troubles to import csv file, when some fields contained CRLF(\r\n).
Row delimiter needs to be changed.
Notepad++ was used.

It matches 15 columns (14 comma delimiters). CRLF is end of line. Some text columns contain CRLF(\r\n).
((?:(?:"(?:(?:""|[^"])+)"|(?:[^,]*)),){14}.*?)\r\n
to add a pipe as row delimiter replace with \1|\r\n

it matches $$ delimiter 7 fields (6 delimiters) and end of line \r MAKE sure . dot matches end of LINE!
(?:.*?\$\$){6}.*?\r
((?:.*?\$\$){13}.*?)\r\n   to add a pipe as row delimiter replace with \1|\r\n 

to search for $$ with grep (Linux or Cygwin), use single quotes and escape last dollar
grep -e '$\$' filename.csv

CPU and system info on Windows

Just few examples of wmic utility to get CPU and system info
wmic cpu get /format:list
or
wmic cpu list full /format:list

to get some particular field
wmic cpu get deviceid,SocketDesignation

system info
wmic COMPUTERSYSTEM list full /format:list
wmic COMPUTERSYSTEM get name,model,NumberOfProcessors /format:list

help
wmic /?
wmic cpu /?
etc.

systeminfo
use /S to connect to remote host