DEV Community

chanduthedev
chanduthedev

Posted on

2

Best way to add line numbers to the large file!!

Recently I started working on Machine Learning project. So started working on large uncleaned data files to clean and learned one of this tip today.

To add line numbers to large file just run below command on the file.


cat -n  file_name >new_file_name

Enter fullscreen mode Exit fullscreen mode

Above command will add the line number at the start of each line from file_name separated by tab and store in new_file_name without effecting the content of the file file_name.

If you want to replace tab with any character like comma, pipe(|) etc. Run below command.


cat -n  file_name | sed 's/\t/\,/g' >new_file_name

Enter fullscreen mode Exit fullscreen mode

OR


cat -n  file_name | tr '\\t' ',' >new_file_name

Enter fullscreen mode Exit fullscreen mode

Some times Mac systems may not identify tab(\t). Press Cntrl + V and press tab to identify tab key in Mac.

API Trace View

How I Cut 22.3 Seconds Off an API Call with Sentry 🕒

Struggling with slow API calls? Dan Mindru walks through how he used Sentry's new Trace View feature to shave off 22.3 seconds from an API call.

Get a practical walkthrough of how to identify bottlenecks, split tasks into multiple parallel tasks, identify slow AI model calls, and more.

Read more →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs