Solved

is csv file in ansi format

Posted on 2014-03-12
5
1,322 Views
Last Modified: 2014-03-24
how can we know what format the csv flat file was saved as? ANSI or UNICODE or UTF-8?
0
Comment
Question by:25112
  • 3
  • 2
5 Comments
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39924524
Header. Look at the first bytes.

Unicode: FF FE
UTF8: EF BB BF

HTH,
Dan
0
 
LVL 5

Author Comment

by:25112
ID: 39926114
Dan, can you guide me how to find the header info. I used CSVed.exe, but i don't spot the header there..

thanks.
0
 
LVL 34

Accepted Solution

by:
Dan Craciun earned 500 total points
ID: 39926212
Here's a simple PowerShell script to test the first bytes:
#test if a file is ASCII, Unicode or UTF-8 encoded
#Q_28386979 on E-E
$inputFile="X:\your\path\file.csv"

$encoding = "ASCII"
$firstBytes = get-content $inputFile -Encoding Byte -TotalCount 3

if ($firstBytes[0] -eq 239 -and $firstBytes[1] -eq 187 -and $firstBytes[2] -eq 191) {
    $encoding = "UTF-8"
} elseif ($firstBytes[0] -eq 255 -and $firstBytes[1] -eq 254) {
    $encoding = "Unicode"
}

echo $encoding

Open in new window

Replace "X:\your\path\file.csv" with your actual file.

The script will read the first 3 bytes from the file and output the encoding.

HTH,
Dan
0
 
LVL 5

Author Comment

by:25112
ID: 39952354
nice, thank you! :)
0
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39952361
Glad I could help!
0

Featured Post

Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question