1

I am trying to extract the variable "flash_lon" from a file and output to a text file in plain text - using ncks.

When I use the following command, it displays the variables I need on screen and outputs to a file.

ncks -v flash_lon -x file.nc output.txt

However, the file is not in readable text. In the documentation for ncks, it says that "ncks will print netCDF data in ASCII format ".

What do I need to do in order to simply extract the variable to text? It is just text. I have attached an image below showing the data in the command line working, surely there must be a way to get it to output. I am on Windows 10.

enter image description here

1 Answer 1

2

If you have ncdump and sed you can output just the data only like this

 ncdump -v flash_lon file.nc | sed -e '1,/data:/d' -e '$d' > output.txt

A solution I use frequently and found here:

https://www.unidata.ucar.edu/mailing_lists/archives/netcdfgroup/2011/msg00317.html

If you don't want even the first lines with the variable name, you can cut those with tail:

 ncdump -v flash_lon file.nc | sed -e '1,/data:/d' -e '$d' | tail -n +3 > output.txt
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.