Urgent.News

What's breaking now, across thousands of outlets.

Tech

CSV 열이 밀렸을 때: 쉼표를 세기 전에 따옴표와 줄바꿈 확인하기

CSV를 받았는데 일부 행의 열이 밀려 보인다면, 쉼표를 지우기 전에 파일이 어떻게 나뉘는지부터 확인해야 합니다. 문장 안의 쉼표는 내용일 수 있고, 셀 안의 줄바꿈도 한 레코드에 속할 수 있습니다. 가상의 요청 목록 네 건으로 이 차이를 살펴보겠습니다. 실제 업무 자료는 쓰지 않았으며, 이번 검사는 문자 깨짐이나 숫자 변환이 아닌 CSV의 필드 개수에 집중합니다. 1. 쉼표 하나가 언제나 열 하나는 아닙니다 T001,"회의실, 장비 확인",open에는 쉼표가 세 개 있습니다. 단순히 쉼표로 나누면 네 조각이 되지만, 큰따옴표로 감싼 “회의실, 장비 확인”은 한 필드입니다. CSV로 읽은 결과는 세 필드입니다. 필드 안에 줄바꿈이 들어 있는 경우도 같습니다. 따옴표가 다음 줄에서 닫히면 화면상의 두 줄이…

발생한 문제: CSV 열이 밀려 보이는 경우를 살펴보고 쉼표와 줄바꿈을 확인하는 방법을 소개합니다.

관련 정보: 문제 발생에 대해 논의한 내용은 다음과 같습니다.

1. 단일 쉼표가 항상 열을 나타내는 것은 아닙니다. 쉼표 뒤에는 셀 내의 줄바꿈이 포함될 수 있습니다.

2. 필드 안에 줄바꿈이 있을 수 있으며, 이 경우 따옴표로 감싸져 다음 줄에서 닫힐 수 있습니다.

3. 필드 개수와 열 수를 비교하여 차이점을 파악해야 합니다. Python의 csv.reader를 사용하여 필드 수가 예상한 3개와 일치하는지 확인하며, 불일치가 있는 레코드를 나열합니다.

4. 따옴표 오류와 열 수 오류는 다릅니다. 닫히지 않은 따옴표는 예외를 발생시키지만, 열 수 오류는 데이터를 읽어들이는 것만으로 성공할 수 있습니다.

5. 너비가 일치해도 불일치를 검사해야 합니다. 마지막 값이 비어 있는 경우도 필드 수가 세 개로 계산됩니다.

이번 검사 결과는 예상한 필드 수가 세 개인 레코드가 두 건이고, 필드 수가 두 건으로 불일치했습니다. 이러한 차이를 파악하는 것은 CSV의 파싱 오류를 확인하기 위한 기본적인 체크입니다.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

How to see which companies are hiring right now (and what changed this week) from Greenhouse, Lever, Ashby and Workday boards

A company's open roles hint at where its money is going next. If it adds five enterprise Account Executives in Germany, it probably plans to sell harder there.

  • Job boards provide insights into company hiring trends
  • Public JSON data from Greenhouse, Lever, Ashby, Workday can be accessed directly
  • Python script compares job listings from last week to current data

Everything You Need to Know About Microservices

Everything You Need to Know About Microservices Microservices are one of the most discussed architecture styles in software, and one of the most misunderstood.

  • Microservices are small, independently deployable services owning one business capability
  • Trade-offs include independent scaling, better technology fit, fault isolation, and faster releases
  • Challenges include network unreliability, data consistency, increased operational overhead

Nike's longest-running Meta ads don't sell shoes. They sell the Nike App

Here's a number I didn't expect: 38 of 150 active Nike ads on Meta use the "Install now" button. Not "Shop now", not "Learn more". Install.

  • 38 out of 150 Nike ads on Meta use "Install now" button instead of "Shop now" or "Learn more"
  • Three longest-running ads (560, 542, and 390 days) are app-install ads

28 Free Browser-Based Writing & Editing Tools for Developers and Content Creators

Developers write more than we admit: READMEs, docs, commit messages, release notes, blog posts, emails to stakeholders. Good writing tools help, but most want an account or upload your draft to a…

  • 28 free browser-based writing tools aid developers in creating various documents.
  • Speech synthesis engine reads text aloud with adjustable speech rates, pitch, and volume.
  • Dictate directly into live transcript with 20 language support and editing capabilities.

More from Sunday 18 October →