Metadata-Version: 2.4
Name: easycsv-py
Version: 5.0.1
Summary: A lightweight, zero-dependency Python library for reading, writing, querying, and joining CSV files.
Home-page: https://github.com/yourusername/easycsv
Author: Your Name
Author-email: your@email.com
Keywords: csv pandas lightweight query join
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Utilities
Classifier: Intended Audience :: Developers
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license-file
Dynamic: requires-python
Dynamic: summary

# easycsv

A lightweight, **zero-dependency** Python library for reading, writing, querying, and joining CSV files — with a syntax far simpler than pandas.

```bash
pip install easycsv-py
```

---

## Quick Start

```python
from easycsv import CSV

data = CSV.load("people.csv")

# Bracket syntax
print(data["name"].values())   # all names
print(data[0])                 # first row
print(data[0:3])               # first 3 rows as new CSV

# SQL-style query (auto-converts "25" -> 25)
adults = data.query("age > 18 and city == 'Boston'")
print(adults.values("name"))

# Membership check
if not data.contains_in("email", "alice@example.com"):
    data.add_row({"name": "Alice", "email": "alice@example.com", "age": "22"})

data.save()
```

---

## Features

### File Operations
```python
data = CSV.load("path/to/file.csv")
data = CSV.create("path/to/new.csv", headers=["name", "age", "city"])
data.save()
data.save("backup/file.csv")   # saves to a new path, creates folders
```

### Row Operations
```python
data.get_row(0)
data.add_row({"name": "Bob", "age": "30"})
data.insert_row(2, {"name": "Alice", "age": "22"})
data.edit_row(0, {"name": "Bob", "age": "35"})
data.delete_row(0)
data.get_row_index({"name": "Bob", "age": "35"})
```

### Column Operations
```python
data.get_column("age")          # plain list
data.column("age")              # ColumnSet with analytics
data.add_column("country", "USA")
data.delete_column("city")
data.drop_columns("city", "zip")
data.rename_column("age", "Age")
data.edit_column("age", lambda x: str(int(x) + 1))
```

### Cell Operations
```python
data.get_cell(0, "name")
data.edit_cell(0, "name", "Alice")
```

### Bracket Syntax
```python
data["age"]           # ColumnSet
data[0]               # row dict
data[0:5]             # new CSV object (slice)
data["status"] = "Active"          # set whole column
data["score"] = [90, 85, 99]       # set column from list
data[0] = {"name": "Bob", ...}     # replace row
```

### Searching
```python
data.find_rows("city", "Boston")          # RowSet
data.find_rows_by_value("Boston")         # RowSet (searches everywhere)
data.find_row_indexes("city", "Boston")   # plain list of indexes
data.find_column("age")                   # plain list of values
data.find_columns("na")                   # headers containing "na"
data.find_columns_by_value("Boston")      # headers whose column contains value
data.find_cells("John")                   # [(row_index, col_name), ...]
data.search("city", "Boston")             # alias for find_rows
```

### Membership Checking
```python
data.contains("John")                        # anywhere in CSV
data.contains_in("email", "a@example.com")  # in specific column
data.row_exists(name="Alice", age="22")      # exact row match
data.column_exists("email")                  # header check
```

### Filtering & Updating
```python
data.where(city="Boston")                    # RowSet
data.filter(city="Boston", age="22")         # alias for where
data.update("city", "Boston", status="VIP")  # update matching rows
data.delete_where(status="Banned")           # delete matching rows
```

### SQL-Style Query
```python
# Strings auto-convert to numbers for math comparisons
results = data.query("age > 20 and city == 'Boston'")
results = data.query("score >= 90 or status == 'VIP'")
```

### CSV Joins
```python
users = CSV.load("users.csv")
orders = CSV.load("orders.csv")

users.join(orders, on="user_id", how="left")   # left join
users.join(orders, on="user_id", how="inner")  # inner join
```

### Analytics
```python
data.sum("price")
data.avg("age")
data.min("score")
data.max("score")
data.unique("city")
data.count("city")    # {"Boston": 3, "NY": 5}
```

### RowSet (returned by searches/queries)
```python
rows = data.find_rows("city", "Boston")

rows.values("name")   # ['Alice', 'Bob']
rows.first()          # first matched row dict
rows.last()           # last matched row dict
rows.indexes()        # [2, 5, 7]
rows.count()          # 3
rows.update(status="VIP")
rows.delete()

for row in rows:      # iterable
    print(row)
```

### ColumnSet (returned by column access)
```python
col = data["age"]

col.values()     # ['25', '30', '22']
col.sum()
col.avg()
col.min()
col.max()
col.unique()
col.count()      # {"25": 1, "30": 2}
col.contains("25")
```

### Utilities
```python
data.sort("age")
data.sort("age", reverse=True)
data.remove_duplicates()
data.remove_duplicates(column="email")
data.reverse()
data.shuffle()
data.select("name", "age")    # returns new CSV with only those columns
data.copy()                   # deep copy
data.head(5)                  # print first 5 rows
data.tail(5)                  # print last 5 rows
data.show()                   # print full table
data.to_list()                # list of dicts
data.to_dict("name")          # dict keyed by column
data.to_json()                # JSON string
data.from_list([{"name": "Alice", "age": "22"}])
len(data)                     # row count
repr(data)                    # CSV('file.csv', 3 rows, 4 columns)
```

---

## Why easycsv?

| Feature | easycsv | pandas |
|---|---|---|
| Dependencies | 0 | numpy, etc. |
| Install size | ~10 KB | ~30 MB |
| Learning curve | Easy | Steep |
| CSV joins | Yes | Yes |
| SQL-style queries | Yes | Yes |
| Best for | Scripts, APIs, bots | Big data, ML |

---

## License

MIT
