Solved

is csv file in ansi format

Posted on 2014-03-12
5
1,202 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now